Approx decimal sequence mapping (#8422)
This commit is contained in:
@@ -313,6 +313,12 @@ class TestApprox:
|
||||
assert approx(expected, rel=5e-7, abs=0) == actual
|
||||
assert approx(expected, rel=5e-8, abs=0) != actual
|
||||
|
||||
def test_list_decimal(self):
|
||||
actual = [Decimal("1.000001"), Decimal("2.000001")]
|
||||
expected = [Decimal("1"), Decimal("2")]
|
||||
|
||||
assert actual == approx(expected)
|
||||
|
||||
def test_list_wrong_len(self):
|
||||
assert [1, 2] != approx([1])
|
||||
assert [1, 2] != approx([1, 2, 3])
|
||||
@@ -346,6 +352,14 @@ class TestApprox:
|
||||
assert approx(expected, rel=5e-7, abs=0) == actual
|
||||
assert approx(expected, rel=5e-8, abs=0) != actual
|
||||
|
||||
def test_dict_decimal(self):
|
||||
actual = {"a": Decimal("1.000001"), "b": Decimal("2.000001")}
|
||||
# Dictionaries became ordered in python3.6, so switch up the order here
|
||||
# to make sure it doesn't matter.
|
||||
expected = {"b": Decimal("2"), "a": Decimal("1")}
|
||||
|
||||
assert actual == approx(expected)
|
||||
|
||||
def test_dict_wrong_len(self):
|
||||
assert {"a": 1, "b": 2} != approx({"a": 1})
|
||||
assert {"a": 1, "b": 2} != approx({"a": 1, "c": 2})
|
||||
|
||||
Reference in New Issue
Block a user