diff --git a/changelog/4327.bugfix.rst b/changelog/4327.bugfix.rst index 0b498cd09..72223af4e 100644 --- a/changelog/4327.bugfix.rst +++ b/changelog/4327.bugfix.rst @@ -1 +1 @@ -Loosen the definition of what ``approx`` considers a sequence +``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``. diff --git a/testing/python/approx.py b/testing/python/approx.py index 0a91bb08f..26e6a4ab2 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -497,12 +497,13 @@ class TestApprox(object): assert approx(expected, rel=5e-7, abs=0) == actual assert approx(expected, rel=5e-8, abs=0) != actual - def test_generic_iterable_sized_object(self): - class newIterable(object): + def test_generic_sized_iterable_object(self): + class MySizedIterable(object): def __iter__(self): return iter([1, 2, 3, 4]) def __len__(self): return 4 - assert [1, 2, 3, 4] == approx(newIterable()) + expected = MySizedIterable() + assert [1, 2, 3, 4] == approx(expected)