Skip to content

Commit a430d0e

Browse files
committed
normalize outcome plurality for pytest compat
pytest-dev/pytest#6505
1 parent 16abc59 commit a430d0e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

testing/test_basic.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
ASYNC_GENERATORS = sys.version_info >= (3, 6)
1212

1313

14+
# https://github.com/pytest-dev/pytest/issues/6505
15+
def force_plural(name):
16+
if name in {"error", "warning"}:
17+
return name + "s"
18+
19+
return name
20+
21+
1422
def assert_outcomes(run_result, outcomes):
1523
formatted_output = format_run_result_output_for_assert(run_result)
1624

@@ -19,8 +27,13 @@ def assert_outcomes(run_result, outcomes):
1927
except ValueError:
2028
assert False, formatted_output
2129

30+
normalized_outcomes = {
31+
force_plural(name): outcome
32+
for name, outcome in result_outcomes.items()
33+
}
34+
2235
for name, value in outcomes.items():
23-
assert result_outcomes.get(name) == value, formatted_output
36+
assert normalized_outcomes.get(name) == value, formatted_output
2437

2538

2639
def format_run_result_output_for_assert(run_result):

0 commit comments

Comments
 (0)