Skip to content

Commit

Permalink
normalize outcome plurality for pytest compat
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Jan 18, 2020
1 parent 16abc59 commit a430d0e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion testing/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
ASYNC_GENERATORS = sys.version_info >= (3, 6)


# https://github.com/pytest-dev/pytest/issues/6505
def force_plural(name):
if name in {"error", "warning"}:
return name + "s"

return name


def assert_outcomes(run_result, outcomes):
formatted_output = format_run_result_output_for_assert(run_result)

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

normalized_outcomes = {
force_plural(name): outcome
for name, outcome in result_outcomes.items()
}

for name, value in outcomes.items():
assert result_outcomes.get(name) == value, formatted_output
assert normalized_outcomes.get(name) == value, formatted_output


def format_run_result_output_for_assert(run_result):
Expand Down

0 comments on commit a430d0e

Please sign in to comment.