Skip to main content

A test suite for adapter plugins.

Installation and use

pip install pytest-dbt-adapter

You'll need to install this package with pip install pytest-dbt-adapter and write a specfile, which is a yaml file ending in .dbtspec. See the included spark/postgres examples in specs. You can also write custom test sequences and override existing default projects.

After installing this package, you should be able to run your spec with pytest path/to/mytest.dbspec. You'll need dbt-core and your adapter plugin installed in the environment as well.

This package also includes a module named dbt_adapter_tests that includes helpers for writing integration tests with Python if necessary. For maintainability purposes, this should only be used as a last resort for scenarios that are impossible to capture with a specfile.

Specs

A spec is composed of a minimum of two things:

  • a target block
  • a sequences block
    • The keys are test names. You can select from these names with pytest's -k flag.
    • The values are test sequence definitions.

Optionally, there is also:

  • a projects block

Targets

A target block is just like a target block you'd use in dbt core. However, there is one special change: the schema field should include a {{ var('_dbt_random_suffix') }} somewhere that the test suite will insert.

Sequences

A sequence has a name (the sequence name), a project (the project name to use), and sequence (a collection of test steps). You can declare new sequences inline, or use the name of a builtin sequence. A sequence itself is just a list of steps. You can find examples in the form of the builtin sequences in the sequences/ folder.

You are encouraged to use as many sequences as you can from the built-in list without modification.

Projects

The minimum project contains only a name field. The value is the name of the project - sequences include a project name.

A project also has an optional paths block, where the keys are relative file paths (to a dbt_project.yml that will be written), and the values are the contents of those files.

There is a dbt_project_yml block, which should be a dictionary that will be updated into the default dbt_project.yml (which sets name, version, and config-version).

Instead of declaring a name field, a project definition may have an overrides field that names a builtin project. The test suite will update the named builtin project with those overrides, instead of overwriting the full project with a new one.

Metadata

Release files for pytest-dbt-adapter 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-dbt-adapter 0.6.0
File Size Uploaded
pytest-dbt-adapter-0.6.0.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-dbt-adapter 0.6.0
File Interpreter ABI Platform
pytest_dbt_adapter-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 42.2 kB

Release files / pytest-dbt-adapter-0.6.0.tar.gz

Download URL pytest-dbt-adapter-0.6.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
83cc43fabc98d5e5591b626674c8c3dd7e9ccff7c45c1c0195cb8778803e770d
BLAKE2b-256 checksum
How to use checksums
1dcc6956f9599535960bb7383c64904509135d409bd7b91a571ef10ebb8f896a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

Release files / pytest_dbt_adapter-0.6.0-py3-none-any.whl

Download URL pytest_dbt_adapter-0.6.0-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c0224f99ca70233165f525cf47fdd42e9adfb4a476914c807cebb283f0129e2
BLAKE2b-256 checksum
How to use checksums
e6e12bc5f33d23db8c9a89ad3801e8b680e17e76313d1df4cbc5e09ae7a00a9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

1 release file

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page