Skip to main content

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 to tests 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_project.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 of dlt_plus the package is part of tests, 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.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.