Skip to content

Commit c10559a

Browse files
committed
Refactor tests
1 parent 1639c81 commit c10559a

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

hypothesis-python/tests/cover/test_control.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_does_not_suppress_exceptions():
7474

7575

7676
def test_suppresses_exceptions_in_teardown():
77-
with pytest.raises(ValueError) as err:
77+
with pytest.raises(ValueError) as exc_info:
7878
with bc():
7979

8080
def foo():
@@ -83,12 +83,12 @@ def foo():
8383
cleanup(foo)
8484
raise AssertionError
8585

86-
assert isinstance(err.value, ValueError)
87-
assert isinstance(err.value.__cause__, AssertionError)
86+
assert isinstance(exc_info.value, ValueError)
87+
assert isinstance(exc_info.value.__cause__, AssertionError)
8888

8989

9090
def test_runs_multiple_cleanup_with_teardown():
91-
with pytest.raises(ExceptionGroup) as err:
91+
with pytest.raises(ExceptionGroup) as exc_info:
9292
with bc():
9393

9494
def foo():
@@ -101,9 +101,9 @@ def bar():
101101
cleanup(bar)
102102
raise AssertionError
103103

104-
assert isinstance(err.value, ExceptionGroup)
105-
assert isinstance(err.value.__cause__, AssertionError)
106-
assert {type(e) for e in err.value.exceptions} == {ValueError, TypeError}
104+
assert isinstance(exc_info.value, ExceptionGroup)
105+
assert isinstance(exc_info.value.__cause__, AssertionError)
106+
assert {type(e) for e in exc_info.value.exceptions} == {ValueError, TypeError}
107107
assert _current_build_context.value is None
108108

109109

hypothesis-python/tests/nocover/test_interesting_origin.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,5 @@ def test_fn(x, y):
5858
# Indirection to fix https://github.com/HypothesisWorks/hypothesis/issues/2888
5959
return function(x, y)
6060

61-
try:
61+
with pytest.raises(MultipleFailures):
6262
test_fn()
63-
except MultipleFailures:
64-
pass
65-
else:
66-
raise AssertionError("Expected MultipleFailures")

hypothesis-python/tests/nocover/test_targeting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_threshold_problem(x):
2929
@pytest.mark.parametrize("multiple", [False, True])
3030
def test_reports_target_results(testdir, multiple):
3131
script = testdir.makepyfile(TESTSUITE.format("" if multiple else "# "))
32-
result = testdir.runpytest(script)
32+
result = testdir.runpytest(script, "--tb=native")
3333
out = "\n".join(result.stdout.lines)
3434
assert "Falsifying example" in out
3535
assert "x=101" in out

0 commit comments

Comments
 (0)