Describe the bug
autotest/test_binaryfile.py applies two marks to the mf6_gwf_2sp_st_tr fixture:
@pytest.fixture
@pytest.mark.mf6
@requires_exe("mf6")
def mf6_gwf_2sp_st_tr(function_tmpdir):
pytest has never honored marks on a fixture. Under pytest 8 this is a warning and the marks are silently dropped:
PytestRemovedIn9Warning: Marks applied to fixtures have no effect
Because requires_exe("mf6") is dropped, test_read_mf6_2sp (the only test that uses the fixture) is not skipped when mf6 is not installed. It fails instead:
FAILED autotest/test_binaryfile.py::test_read_mf6_2sp - FileNotFoundError: The program mf6 does not exist or is not executable.
Under pytest 9 the warning became an error, and it aborts collection of the whole module rather than the one test:
ERROR autotest/test_binaryfile.py - Failed: Marks cannot be applied to fixtures.
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
To Reproduce
The dead guard is reproducible on the current pytest:
- Install flopy's test dependencies without the mf6 executable on
PATH
pytest autotest/test_binaryfile.py::test_read_mf6_2sp
- The test fails with
FileNotFoundError rather than being skipped
The collection error needs pytest 9:
pip install "pytest==9.1.1"
pytest autotest/test_binaryfile.py --co
- Collection of all 46 tests in the module is aborted
Expected behavior
test_read_mf6_2sp should be skipped when mf6 is not installed, and test_binaryfile.py should collect on pytest 9.
Moving both marks from the fixture to test_read_mf6_2sp does this. With that change pytest 9.1.1 and pytest 8.4.2 produce identical results across the suite.
Additional context
flopy does not currently install pytest 9 — syrupy <5.0.0 resolves to syrupy 4.9.1, which requires pytest >=7.0.0,<9.0.0. flopy's own constraint is only pytest !=8.1.0, so relaxing the syrupy pin lets pytest 9 in and turns this into a collection failure. The dead requires_exe guard is present today regardless of the pytest version.
This is the only fixture in the repository with a mark applied to it.
Describe the bug
autotest/test_binaryfile.pyapplies two marks to themf6_gwf_2sp_st_trfixture:pytest has never honored marks on a fixture. Under pytest 8 this is a warning and the marks are silently dropped:
Because
requires_exe("mf6")is dropped,test_read_mf6_2sp(the only test that uses the fixture) is not skipped when mf6 is not installed. It fails instead:Under pytest 9 the warning became an error, and it aborts collection of the whole module rather than the one test:
To Reproduce
The dead guard is reproducible on the current pytest:
PATHpytest autotest/test_binaryfile.py::test_read_mf6_2spFileNotFoundErrorrather than being skippedThe collection error needs pytest 9:
pip install "pytest==9.1.1"pytest autotest/test_binaryfile.py --coExpected behavior
test_read_mf6_2spshould be skipped when mf6 is not installed, andtest_binaryfile.pyshould collect on pytest 9.Moving both marks from the fixture to
test_read_mf6_2spdoes this. With that change pytest 9.1.1 and pytest 8.4.2 produce identical results across the suite.Additional context
flopy does not currently install pytest 9 —
syrupy <5.0.0resolves to syrupy 4.9.1, which requirespytest >=7.0.0,<9.0.0. flopy's own constraint is onlypytest !=8.1.0, so relaxing the syrupy pin lets pytest 9 in and turns this into a collection failure. The deadrequires_exeguard is present today regardless of the pytest version.This is the only fixture in the repository with a mark applied to it.