Instruction file imported from pixeltable/pixeltable (
.github/instructions/tests.instructions.md). Copyright stays with the author.
- New features need tests here; the tree mirrors
pixeltable/. - A test that runs against every catalog mode takes
db_root: DatabaseRootand builds paths withdb_root.make_catalog_path(...). Prefer this for new tests. - A test limited to the in-process catalog, such as one that monkeypatches in-process state, takes
uses_dband uses plain catalog paths. Do not flag its catalog paths. - A test using
uses_dbneeds@pytest.mark.db_roots('local', reason='...');tests/conftest.pyraises aUsageErrorat collection without it. The reason states why the test cannot run on the other catalog modes, or isTODO: convertfor a test not yet converted todb_root. - Any test for
pxt.Erroror a subclass usespxt_raises(), notpytest.raises(). Both always takematch=to verify error text. - Assert on user-visible behavior through the public API, not
col.stored,ColumnRef, orTableVersioninternals. UseTable.get_metadata(),t.describe(), or queries. - Avoid using the internal API as much as possible. Only use it to test behaviors that are very difficult or impossible to reproduce using only the public API.
- AI provider tests go in
tests/functions/test_<provider>.py, markedremote_api. Anything hitting a third-party model or service also needsvery_expensive. - Never dodge one backend with a bare
@pytest.mark.skip. Scope it withdb_roots. Register any new marker inpyproject.toml. - No
http://orhttps://literals. Use thesample_file_serverfixture, which serves the repo tree over localhost and still exercises the download path. - A
skipif/xfailon a test parametrized over catalog mode disables every variant. Gate inside the test body when the reason names one parametrization. - Prefer extending an existing parametrized test over adding a bespoke one beside it.
- Test names must be specific enough for
pytest -k. Preferpytest.parametrizeover duplication. - Use the shared utilities (
validate_update_status(),skip_test_if_not_installed(),ReloadTester) and extend shared fixtures rather than duplicating setup. - Put markers on the class or method, not in a module-level
pytestmark.
