pytest Helpers¶
The pytest helpers keep session functions short while still letting you pass
through nox positional arguments and custom environment variables. They are a
thin layer over pytest, not a new test runner API.
liblaf.nox_recipes.pytest
¶
pytest(
s: Session,
*,
cov: bool = True,
eager_import: bool = True,
env: Mapping[str, str | None] | None = None,
suppress_no_test_exit_code: bool = False,
) -> None
Run pytest for the current session.
Parameters:
-
(s¶Session) –The active
noxsession. -
(cov¶bool, default:True) –Whether to pass
--covtopytest. -
(eager_import¶bool, default:True) –Whether to set
EAGER_IMPORT=1for the test command. -
(env¶Mapping[str, str | None] | None, default:None) –Extra environment variables merged into the
pytestprocess. -
(suppress_no_test_exit_code¶bool, default:False) –Whether to treat
pytestexit code5("no tests collected") as a successful run.
Source code in src/liblaf/nox_recipes/_pytest.py
liblaf.nox_recipes.pytest_bench
¶
pytest_bench(
s: Session,
*,
eager_import: bool = True,
env: Mapping[str, str | None] | None = None,
suppress_no_test_exit_code: bool = False,
) -> None
Run the benchmark subset with CodSpeed-friendly defaults.
This helper runs pytest -m benchmark --codspeed. If pytest-xdist is
installed in the session environment, it also adds --numprocesses=0 so
benchmarks stay single-process and deterministic.
Parameters:
-
(s¶Session) –The active
noxsession. -
(eager_import¶bool, default:True) –Whether to set
EAGER_IMPORT=1for the test command. -
(env¶Mapping[str, str | None] | None, default:None) –Extra environment variables merged into the
pytestprocess. -
(suppress_no_test_exit_code¶bool, default:False) –Whether to treat
pytestexit code5("no tests collected") as a successful run.
Source code in src/liblaf/nox_recipes/_pytest.py
liblaf.nox_recipes.pytest_plugin_versions
¶
Return installed pytest plugin versions for the session.
The result is parsed from pytest --version --version, which reports each
discovered plugin on its own line.
Parameters:
-
(s¶Session) –The active
noxsession.
Returns: