test: add test case for #11414
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# pragma pylint: disable=missing-docstring, protected-access, invalid-name
|
# pragma pylint: disable=missing-docstring, protected-access, invalid-name
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
from math import isnan, nan
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from ccxt import (
|
from ccxt import (
|
||||||
@@ -321,6 +322,7 @@ def test_amount_to_precision(
|
|||||||
(2.9977, TICK_SIZE, 0.005, 3.0, ROUND),
|
(2.9977, TICK_SIZE, 0.005, 3.0, ROUND),
|
||||||
(234.24, TICK_SIZE, 0.5, 234.0, ROUND),
|
(234.24, TICK_SIZE, 0.5, 234.0, ROUND),
|
||||||
(234.26, TICK_SIZE, 0.5, 234.5, ROUND),
|
(234.26, TICK_SIZE, 0.5, 234.5, ROUND),
|
||||||
|
(nan, TICK_SIZE, 3, nan, ROUND),
|
||||||
# Tests for TRUNCATTE
|
# Tests for TRUNCATTE
|
||||||
(2.34559, DECIMAL_PLACES, 4, 2.3455, TRUNCATE),
|
(2.34559, DECIMAL_PLACES, 4, 2.3455, TRUNCATE),
|
||||||
(2.34559, DECIMAL_PLACES, 5, 2.34559, TRUNCATE),
|
(2.34559, DECIMAL_PLACES, 5, 2.34559, TRUNCATE),
|
||||||
@@ -359,10 +361,11 @@ def test_amount_to_precision(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_price_to_precision(price, precision_mode, precision, expected, rounding_mode):
|
def test_price_to_precision(price, precision_mode, precision, expected, rounding_mode):
|
||||||
assert (
|
result = price_to_precision(price, precision, precision_mode, rounding_mode=rounding_mode)
|
||||||
price_to_precision(price, precision, precision_mode, rounding_mode=rounding_mode)
|
if not isnan(expected):
|
||||||
== expected
|
assert result == expected
|
||||||
)
|
else:
|
||||||
|
assert isnan(result)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
Reference in New Issue
Block a user