Skip to content

Commit

Permalink
DX: print reasons for skipping tests (#378)
Browse files Browse the repository at this point in the history
* MAINT: improve skip logic
  • Loading branch information
redeboer authored Dec 21, 2023
1 parent cb10eaa commit aaf585b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ addopts = '''
--durations=3
--ignore=docs/abbreviate_signature.py
--ignore=docs/conf.py
-m "not slow"'''
-m "not slow"
-rS
'''
filterwarnings = [
"error",
"ignore:.*invalid value encountered in sqrt.*:RuntimeWarning",
Expand Down
9 changes: 6 additions & 3 deletions tests/sympy/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
)
def test_get_readable_hash(assumptions, expected_hash, caplog: LogCaptureFixture):
if sys.version_info < (3, 8) or sys.version_info >= (3, 11):
pytest.skip("Cannot run this test on Python 3.7")
python_version = ".".join(map(str, sys.version_info[:2]))
pytest.skip(f"Cannot run this test on Python {python_version}")
caplog.set_level(logging.WARNING)
x, y = sp.symbols("x y", **assumptions)
expr = x**2 + y
h = get_readable_hash(expr)
python_hash_seed = os.environ.get("PYTHONHASHSEED")
if python_hash_seed is None or not python_hash_seed.isdigit():
if python_hash_seed is None:
assert h[:7] == "bbc9833"
if _warn_about_unsafe_hash.cache_info().hits == 0:
assert "PYTHONHASHSEED has not been set." in caplog.text
Expand All @@ -60,7 +61,9 @@ def test_get_readable_hash_energy_dependent_width():
h = get_readable_hash(expr)
python_hash_seed = os.environ.get("PYTHONHASHSEED")
if python_hash_seed is None:
pytest.skip("PYTHONHASHSEED has been set, but is not 0")
pytest.skip("PYTHONHASHSEED has not been set")
if python_hash_seed != "0":
pytest.skip(f"PYTHONHASHSEED is not set to 0, but to {python_hash_seed}")
if sys.version_info < (3, 8):
assert h == "pythonhashseed-0+6939334787254793397"
elif sys.version_info >= (3, 11):
Expand Down

0 comments on commit aaf585b

Please sign in to comment.