Skip to content

Commit

Permalink
Update nocover tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed May 1, 2022
1 parent 17dd739 commit c76e787
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
9 changes: 6 additions & 3 deletions hypothesis-python/tests/nocover/test_scrutineer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,19 @@ def get_reports(file_contents, *, testdir):
for i, line in enumerate(file_contents.splitlines())
if line.endswith(BUG_MARKER)
}
expected = ["\n".join(r) for k, r in make_report(explanations).items()]
expected = [
("\n".join(r), "\n | ".join(r)) # single, ExceptionGroup
for r in make_report(explanations).values()
]
return pytest_stdout, expected


@pytest.mark.parametrize("code", FRAGMENTS)
def test_explanations(code, testdir):
pytest_stdout, expected = get_reports(PRELUDE + code, testdir=testdir)
assert len(expected) == code.count(BUG_MARKER)
for report in expected:
assert report in pytest_stdout
for single, group in expected:
assert single in pytest_stdout or group in pytest_stdout


@pytest.mark.parametrize("code", FRAGMENTS)
Expand Down
14 changes: 5 additions & 9 deletions hypothesis-python/tests/nocover/test_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,9 @@ def snake(self):
def test_bad_machines_fail(machine):
test_class = machine.TestCase
try:
with capture_out() as o:
with raises(AssertionError):
test_class().runTest()
except Exception:
print(o.getvalue())
raise
v = o.getvalue()
print(v)
steps = [l for l in v.splitlines() if "Step " in l or "state." in l]
test_class().runTest()
raise RuntimeError("Expected an assertion error")
except AssertionError as err:
notes = err.__notes__
steps = [l for l in notes if "Step " in l or "state." in l]
assert 1 <= len(steps) <= 50
1 change: 0 additions & 1 deletion hypothesis-python/tests/nocover/test_targeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def test_reports_target_results(testdir, multiple):
assert "Falsifying example" in out
assert "x=101" in out
assert out.count("Highest target score") == 1
assert out.index("Highest target score") < out.index("Falsifying example")
assert result.ret != 0


Expand Down

0 comments on commit c76e787

Please sign in to comment.