Running tests with pytest
The arsgrammatica package includes two kinds of tests:
- off-line tests of the package’s fundamental structures (models of syntax, DSPy signatures for interacting with language models, etc) without any connection to a language model
- live tests that make calls to a configured language model
Off-line testing
The whole pytest suite runs against DummyLM, not a real model. In tests/fixtures/gold_examples.py’s, GOLD_EXAMPLES defines a deliberately curated corpus. test_coverage.py enforces that every documented relation label, verbal-expression classification, and token type has at least one example exercising it.
Tests that call the configured LM are marked live and skipped by default. To run all offline tests:
pytestTesting with a real model
Testing uses the model configured in your .env file. Run the live tests:
pytest -m livepytest cheat sheet
Some standard pytest shorthands:
pytestto run all.pytest -vfor per-test names instead of dots.pytest tests/test_gold_examples.pyto run just one file.pytest -k agentto run only tests matching a substring.pytest --collect-onlyif you just want to see what it discovered without running anything.