Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

aiida-pytest

This is a helper to enable testing AiiDA plugins with pytest. The main purpose is to create a fixture which sets up a temporary AiiDA database and user, and simplify setting up the computers and calculations.

To get started, create a tests folder where your pytest tests will be located. In conftests.py, you need to write

from aiida_pytest import *

This defines the configure and configure_with_daemon fixtures. To set up computers and codes for the test run, you need a config.yml file in the tests folder (and run pytest from there). The following example config file sets up localhost and the bands-inspect code:

computers:
  localhost:
    hostname: localhost
    description: localhost
    transport: local
    scheduler: direct
    work_directory: /tmp/test_aiida
    prepend_text: 'unset PYTHONPATH'

codes:
  bands_inspect:
    description: bands_inspect code
    default_plugin: bands_inspect.difference
    remote_computer: localhost
    remote_abspath: /home/a-dogres/.virtualenvs/bands-inspect/bin/bands-inspect

Note: aiida-pytest is not compatible with the aiida-xdist plugin, since the fixtures with scope=session are then called for each running worker.

Defining and running tests

Tests with aiida-pytest are defined and run exactly like "regular" pytest tests. If a test needs the AiiDA database, it should use the configure fixture. If the test also requires the Daemon to run, it should use the configure_with_daemon fixture. Note that, since certain AiiDA import statements require the database backend to be set, these imports should be done inside the test function.

After the tests have run, the code will wait for you to press Enter before deleting the testing database and repository. This gives you the opportunity to manually inspect the final state. If you want to avoid this step (for example in a CI system), pass the --quiet-wipe flag to py.test.

Metadata

Release files for aiida-pytest 0.1.0a4

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

Source distribution (sdist)

Source distribution for aiida-pytest 0.1.0a4
File Size Uploaded
aiida-pytest-0.1.0a4.tar.gz 6.6 kB Details

Release files / aiida-pytest-0.1.0a4.tar.gz

Download URL aiida-pytest-0.1.0a4.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a3fc8299b1b29305b22b45e0fbcee4fe920e5fe5f20a9aaf8d703597c156b857
BLAKE2b-256 checksum
How to use checksums
05fde930e2f17456c5fff91a9a26aa198df9530a40cb29e9c078e2185dbcd904
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8
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