Pytest reference¶
Custom options¶
Pipeline registers several custom pytest options. To list them all:
casa_python -m pytest --help
Here casa_python is an alias for PYTHONNOUSERSITE=1 ${casa_dir}/bin/python3.
Option |
Description |
|---|---|
|
Collect tests and export node IDs to |
|
Suppress CASA log file creation in the working directory. Note: for regression tests,
logs are still generated inside each test’s |
|
Delete |
|
Skip pipeline execution; compare against existing working-directory results only |
|
Remove individual working directories after regression tests complete |
|
Enable longer-running tests excluded by default |
|
Path to large input data files; defaults to |
Examples¶
Collect test node IDs without running any tests:
casa_python -m pytest -v --collect-tests <pipeline_dir>
Run with parallel execution, suppressing CASA log file creation (keeps the repo directory clean):
casa_python -m pytest -n 4 -v --pyclean --nologfile <pipeline_dir>
Re-evaluate results from a previous run without re-executing the pipeline:
xvfb-run casa --nogui --nologger --log2term --agg -c \
"import pytest; pytest.main(['-vv', '-m alma and fast', '--compare-only', '<pipeline_dir>'])"
Specify a custom data directory for large datasets:
xvfb-run casa --nogui --nologger --log2term --agg -c \
"import pytest; pytest.main(['-vv', '-m alma and slow', \
'--data-directory=/users/kberry/big_data_directory/', '<pipeline_dir>'])"
Custom markers¶
Markers are defined in pyproject.toml. Many are applied automatically by conftest.py
based on the test’s file path; others must be added manually per test function.
Auto-applied markers:
Marker |
Applied to |
|---|---|
|
All tests under |
|
All tests under |
|
All other tests (fallback) |
|
Tests under |
|
Tests under |
|
Regression tests with |
|
Regression tests with |
|
Regression tests with |
|
Regression tests with |
|
Regression tests with |
|
Regression tests with |
Manually applied markers (added with @pytest.mark.<name> per test function):
Marker |
Purpose |
|---|---|
|
12 m ALMA test |
|
7 m ALMA test |
|
Test recommended for an MPI-enabled CASA session; use |
|
Component test involving data import |
|
Component test involving self-calibration |
|
Component test involving imaging |
Select tests with -m:
# run only VLASS tests
xvfb-run casa --nogui --nologger --log2term --agg \
-c "import pytest; pytest.main(['-vv', '-m vlass', '--longtests', '<pipeline_dir>'])"
# combine: fast VLA tests only
xvfb-run casa --nogui --nologger --log2term --agg \
-c "import pytest; pytest.main(['-vv', '-m vla and fast', 'pipeline'])"
# negate: everything except VLASS
xvfb-run casa --nogui --nologger --log2term --agg \
-c "import pytest; pytest.main(['-vv', '-m not vlass', 'pipeline'])"
# regression tests, excluding slow ones
PYTHONNOUSERSITE=1 ${casa_dir}/bin/python3 -m pytest -m "regression and not slow" tests/
# component tests involving self-calibration
PYTHONNOUSERSITE=1 ${casa_dir}/bin/python3 -m pytest -m "component and selfcal" tests/component/
casa-data and pipeline-testdata¶
See Test environment setup for configuring casa-data and pipeline-testdata paths.