Skip to content

Commit 1f6cd9c

Browse files
authored
Merge pull request #4503 from jobh/test-annoyances
Test annoyances
2 parents b8990bd + ea64bff commit 1f6cd9c

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

hypothesis-python/tests/cover/test_database_backend.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,19 @@ def test_database_directory_inaccessible(dirs, tmp_path, monkeypatch):
477477
monkeypatch.setattr(
478478
configuration, "__hypothesis_home_directory", tmp_path.joinpath(*dirs)
479479
)
480-
tmp_path.chmod(0o000)
481-
with (
482-
nullcontext()
483-
if WINDOWS
484-
else pytest.warns(HypothesisWarning, match=".*the default location is unusable")
485-
):
486-
database = _db_for_path(not_set)
487-
database.save(b"fizz", b"buzz")
480+
try:
481+
tmp_path.chmod(0o000)
482+
with (
483+
nullcontext()
484+
if WINDOWS
485+
else pytest.warns(
486+
HypothesisWarning, match=".*the default location is unusable"
487+
)
488+
):
489+
database = _db_for_path(not_set)
490+
database.save(b"fizz", b"buzz")
491+
finally:
492+
tmp_path.chmod(0o600) # So that pytest can clean up tmp_path later
488493

489494

490495
@skipif_emscripten

hypothesis-python/tests/cover/test_traceback_elision.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717

1818
@pytest.mark.parametrize("verbosity", [Verbosity.normal, Verbosity.debug])
19-
def test_tracebacks_omit_hypothesis_internals(verbosity):
19+
@pytest.mark.parametrize("env_value", ["", "1"])
20+
def test_tracebacks_omit_hypothesis_internals(monkeypatch, env_value, verbosity):
21+
monkeypatch.setenv("HYPOTHESIS_NO_TRACEBACK_TRIM", env_value)
22+
2023
@settings(verbosity=verbosity)
2124
@given(st.just(False))
2225
def simplest_failure(x):
@@ -28,7 +31,7 @@ def simplest_failure(x):
2831
tb = traceback.extract_tb(e.__traceback__)
2932
# Unless in debug mode, Hypothesis adds 1 frame - the least possible!
3033
# (4 frames: this one, simplest_failure, internal frame, assert False)
31-
if verbosity < Verbosity.debug:
34+
if verbosity < Verbosity.debug and not env_value:
3235
assert len(tb) == 4
3336
else:
3437
assert len(tb) >= 5

0 commit comments

Comments
 (0)