parent
853f4cd9d8
commit
4658bdcacf
@ -45,6 +45,7 @@ def test_partial_compare_equal(val1, val2):
|
|||||||
({1: 1}, {1: [1]}, "Different types (int, list) -> False"),
|
({1: 1}, {1: [1]}, "Different types (int, list) -> False"),
|
||||||
({'a': [1, 2, 3]}, {'a': [..., 3]}, "2 != 3"),
|
({'a': [1, 2, 3]}, {'a': [..., 3]}, "2 != 3"),
|
||||||
("foo*baz", "foobarbaz", "'foo*baz' != 'foobarbaz' (pattern matching)"),
|
("foo*baz", "foobarbaz", "'foo*baz' != 'foobarbaz' (pattern matching)"),
|
||||||
|
(23.42, 13.37, "23.42 != 13.37 (float comparison)"),
|
||||||
])
|
])
|
||||||
def test_partial_compare_not_equal(val1, val2, error):
|
def test_partial_compare_not_equal(val1, val2, error):
|
||||||
outcome = utils.partial_compare(val1, val2)
|
outcome = utils.partial_compare(val1, val2)
|
||||||
|
@ -26,6 +26,8 @@ import re
|
|||||||
import pprint
|
import pprint
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
class PartialCompareOutcome:
|
class PartialCompareOutcome:
|
||||||
|
|
||||||
@ -84,7 +86,7 @@ def _partial_compare_list(val1, val2, *, indent):
|
|||||||
|
|
||||||
|
|
||||||
def _partial_compare_float(val1, val2, *, indent):
|
def _partial_compare_float(val1, val2, *, indent):
|
||||||
if abs(val1 - val2) < 0.00001:
|
if val1 == pytest.approx(val2):
|
||||||
return PartialCompareOutcome()
|
return PartialCompareOutcome()
|
||||||
|
|
||||||
return PartialCompareOutcome("{!r} != {!r} (float comparison)".format(
|
return PartialCompareOutcome("{!r} != {!r} (float comparison)".format(
|
||||||
|
Loading…
Reference in New Issue
Block a user