From 1e6b495e35c4c362d5d7113563797da05e3ac60d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 14 Apr 2021 11:37:34 +0200 Subject: [PATCH] Adjust enum reprs for Python 3.10 Potential fix for #8546 --- testing/python/metafunc.py | 5 ++++- testing/test_pytester.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 6577ff18ebf..a3b12b2d3b7 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -448,7 +448,10 @@ def test_idmaker_enum(self) -> None: enum = pytest.importorskip("enum") e = enum.Enum("Foo", "one, two") result = idmaker(("a", "b"), [pytest.param(e.one, e.two)]) - assert result == ["Foo.one-Foo.two"] + assert result in [ + ["Foo.one-Foo.two"], + ["one-two"], # Python 3.10 + ] def test_idmaker_idfn(self) -> None: """#351""" diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 7b16c69c23d..64bb491678d 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -744,10 +744,14 @@ def test_run_result_repr() -> None: # known exit code r = pytester_mod.RunResult(1, outlines, errlines, duration=0.5) - assert ( - repr(r) == "" - ) + expected = [ + "", + # Python 3.10 + "", + ] + assert repr(r) in expected # unknown exit code: just the number r = pytester_mod.RunResult(99, outlines, errlines, duration=0.5)