Skip to content

Commit

Permalink
Adjust enum reprs for Python 3.10
Browse files Browse the repository at this point in the history
Potential fix for pytest-dev#8546
  • Loading branch information
The-Compiler committed Apr 14, 2021
1 parent bfcd796 commit 1e6b495
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion testing/python/metafunc.py
Expand Up @@ -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"""
Expand Down
12 changes: 8 additions & 4 deletions testing/test_pytester.py
Expand Up @@ -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) == "<RunResult ret=ExitCode.TESTS_FAILED len(stdout.lines)=3"
" len(stderr.lines)=4 duration=0.50s>"
)
expected = [
"<RunResult ret=ExitCode.TESTS_FAILED len(stdout.lines)=3"
" len(stderr.lines)=4 duration=0.50s>",
# Python 3.10
"<RunResult ret=TESTS_FAILED len(stdout.lines)=3"
" len(stderr.lines)=4 duration=0.50s>",
]
assert repr(r) in expected

# unknown exit code: just the number
r = pytester_mod.RunResult(99, outlines, errlines, duration=0.5)
Expand Down

0 comments on commit 1e6b495

Please sign in to comment.