Merge pull request #4327 from ndevenish/approx

Let approx() work on more generic sequences
This commit is contained in:
Ronny Pfannschmidt
2018-12-17 15:21:12 +01:00
committed by GitHub
5 changed files with 24 additions and 6 deletions

View File

@@ -496,3 +496,14 @@ class TestApprox(object):
assert actual != approx(expected, rel=5e-8, abs=0)
assert approx(expected, rel=5e-7, abs=0) == actual
assert approx(expected, rel=5e-8, abs=0) != actual
def test_generic_sized_iterable_object(self):
class MySizedIterable(object):
def __iter__(self):
return iter([1, 2, 3, 4])
def __len__(self):
return 4
expected = MySizedIterable()
assert [1, 2, 3, 4] == approx(expected)