From 710446420c0bb98f0761724ec865a894820bb610 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 | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 4a4b141c4b7..ce689e56d77 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"] + if sys.version_info[:2] >= (3, 10): + assert result == ["one-two"] + else: + assert result == ["Foo.one-Foo.two"] def test_idmaker_idfn(self) -> None: """#351""" diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 7b16c69c23d..19f28504d88 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -744,10 +744,16 @@ def test_run_result_repr() -> None: # known exit code r = pytester_mod.RunResult(1, outlines, errlines, duration=0.5) - assert ( - repr(r) == "" - ) + if sys.version_info[:2] >= (3, 10): + assert repr(r) == ( + "" + ) + else: + assert repr(r) == ( + "" + ) # unknown exit code: just the number r = pytester_mod.RunResult(99, outlines, errlines, duration=0.5)