Usage
Setup
Here's how test setup works.
It is a pytest
plugin that registers a few basic fixtures, additional pytest-init
options (see below) and pytest_config
:
- see
plugin.py
for a list of fixtures pytest_config
makes sure that project run context exists and switches totests
profile
Two additional pytest ini
options are added (and usually do not need to be changed)
[tool.pytest.ini_options]
dlt_tests_project_path="..."
dlt_tests_project_profile="..."
Suggested conftest.py
There are useful autouse fixtures that should be almost always imported (no autouse fixtures are enabled by default)
from dlt_plus_tests.fixtures import (
auto_preserve_environ as auto_preserve_environ,
drop_pipeline as drop_pipeline,
autouse_test_storage as autouse_test_storage,
auto_cwd_to_tmp_dir as auto_cwd_to_tmp_dir,
)
Many cool utils can be imported from utils.py
(ie. to verify loads, check table counts, inspect metrics)
When tests run
Config setup will activate run context with dlt.yml
of the package being tested. tests
profile will be activated (and must be present).
In the test project run context:
run_dir
points to package being tested (in case ofdlt_plus
the package is part oftests
, otherwise it is a "real" package)data_dir
points to {$HOME}/.dlt/<package_name>/tests/
autouse_test_storage
cleans up tmp_dir
(typically _storage
) folder (in relation to cwd()) and copies tests/.dlt
to it.