بنقرة واحدة
test-runner
Running/writing tests — pytest classes, markers, ref_data regression, debug output paths
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Running/writing tests — pytest classes, markers, ref_data regression, debug output paths
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Before writing new code — search existing implementations, topical audits, READMEs, file-header caveats
After implementing — update file headers, README, topical audits; note duplication
Navigate and debug OrbitalWar / SpaceCraft — design, truss sim, combat, radiosity, orbits; hub to docs and tests
Diagnostic plots/visualizations — shared utilities, output paths, plot style conventions
Dedicated documentation work — OKF format, topical audits, extract-overview and inline-doc workflows
Writing new code — inventory-first, module-vs-script placement, no-new-files, STOP triggers for duplication
| name | test-runner |
| description | Running/writing tests — pytest classes, markers, ref_data regression, debug output paths |
| trigger | {"glob":["**/tests/**/*","**/*test*.py","**/pytest.ini","**/conftest.py","**/doc/TEST_DESIGN.md"]} |
The test system follows the design in doc/TEST_DESIGN.md. Scripts in tests/ fall into three classes:
Scripts containing def test_* functions with assert statements. Run via pytest. These are the primary test suite — they verify numerical correctness, physical consistency, and regression parity.
slow, gpu) to control which tests runasserttest_topology.py, test_forcefield.py, test_surface.py, test_folded_relax.py, SPM/test_afm_morse.py, SPM/test_afm_fdbm.pyScripts run directly via python tests/<script>.py. They compute physics, generate plots, and print metrics — but make no pass/fail assertions. Their purpose is visual review and manual inspection by the user.
def test_* functions)python tests/SPM/plot_fdbm_relax.pydebug/<script_name>/test_folded_surface_scan.py, test_tensor_parity.py, run_manipulation.py, SPM/plot_*.py, SPM/run_afm_morse_visual.pyHelper modules imported by Class 1 and Class 2. Never run directly.
conftest.py, helpers/parity.py, helpers/geometry.py, helpers/scan.py, helpers/folded_rigid.pytests/
conftest.py # fixtures: data paths, molecule loader, --update-refs option
test_topology.py # Class 1: bond/angle/hybridization/type assignment
test_forcefield.py # Class 1: UFF/SPFF optimization, NVE conservation
test_surface.py # Class 1: Ewald vs brute, GridFF, folded function
test_folded_relax.py # Class 1: rigid body relaxation + manipulation on folded basis
test_lingebra.py # Class 1: linear algebra eigenvalue tests
test_integration.py # Class 1: relaxed scan (stubs — TODO)
test_folded_surface_scan.py # Class 2: folded basis fitting + plots
test_tensor_parity.py # Class 2: GPU vs CPU tensor kernel parity + plots
run_manipulation.py # Class 2: CLI run relaxed scan, export .xyz movie
SPM/test_afm_morse.py # Class 1: AFM Morse/LJ force field tests
SPM/test_afm_fdbm.py # Class 1: AFM Full Density-Based Model tests
SPM/plot_density_projection.py # Class 2: DFTB density visualization
SPM/plot_fdbm_potentials.py # Class 2: FDBM potential diagnostics
SPM/plot_fdbm_relax.py # Class 2: FDBM relaxation + AFM images
SPM/run_afm_morse_visual.py # Class 2: Morse AFM visualization
ref_data/ # git-tracked reference files for regression tests
*.ref.json # physical properties (z_rel, force, torque, distances)
*.ref.xyz # final geometry snapshots
helpers/
parity.py # Class 3: rmse, correlation, overlay_plot, assert_parity
geometry.py # Class 3: bond_lengths, angles, planarity, distort
scan.py # Class 3: 1D scan runner (z-scan, x-scan), compare_scans
folded_rigid.py # Class 3: rigid body setup, relaxation, manipulation, reference system
pytest -m "not slow" # default: fast tests only (< 1s each)
pytest -m "not slow and not gpu" # fast, no GPU
pytest -m "gpu" # GPU tests only
pytest # everything (including slow)
pytest --durations=10 # show 10 slowest tests
Markers: slow, gpu (defined in pytest.ini).
slow — tests taking > 1s (hard limit 5s); excluded from default runsgpu — tests requiring OpenCL GPUReference files in tests/ref_data/ are tracked in git — they are permanent regression test data, not debug artifacts.
{ref_name}.ref.json and final geometry as {ref_name}.ref.xyztest_func and test_module fields for bidirectional linkingpytest tests/test_folded_relax.py --update-refs
.ref.json and .ref.xyz files to gittests/TEST_RESULTS.md → "Reference Data System" section for detailsAll diagnostic scripts and visual outputs go to:
$REPO_ROOT/debug/<script_name>/
<script_name> = generating script name without .pydebug/plot_fdbm_relax/dftb_work/)/tmp/ or repository rootDefault test runs must be fast. The goal is to run as many tests as possible in seconds, not minutes.
@pytest.mark.slow@pytest.mark.slow — they are not run by defaultpytest -m "not slow" — fast tests onlypytest — includes slow testspytest --durations=10 to identify the slowest tests@pytest.mark.slow and document why in the docstringStandalone scripts (not pytest tests) produce PNG plots and numerical output for human review. They are run directly:
python tests/test_folded_surface_scan.py
python tests/test_tensor_parity.py
python tests/SPM/plot_fdbm_relax.py
python tests/SPM/run_afm_morse_visual.py
These scripts:
if __name__ == '__main__' blocks, no def test_* functionsdebug/<script_name>/pyBall/SPM/AFM_utils.py and pyBall/SPM/AFM.pytests/helpers/parity.py — rmse, correlation, max_err, overlay_plot, assert_paritytests/helpers/geometry.py — bond_lengths, bond_angle, planarity, distort, check_geometrytests/helpers/scan.py — z_scan, x_scan, compare_scanstests/helpers/folded_rigid.py — setup_rigid_folded, relax_folded, relaxed_scan, plot_relaxed_scan, plot_manipulation_trail, save_reference, compare_to_reference, replicate_substrateBefore writing new test/plot functions, search existing utility modules. Reuse and generalize rather than reimplement.