This release is a pre-release and may not be stable for production use.
NOTE: The aiida-pytest package is in maintenance mode: bugs will continue to be fixed for the foreseeable future, but no new features will be implemented. Users considering using aiida-pytest are strongly encouraged to use the built-in AiiDA fixtures instead.
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.0a8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiida-pytest-0.1.0a8.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiida_pytest-0.1.0a8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / aiida-pytest-0.1.0a8.tar.gz
| Download URL | aiida-pytest-0.1.0a8.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91f8a6d55aa0e28f4630a2eafe4aedbb80ce9e26c8fe91d3ec262bd03ba05486
|
|
BLAKE2b-256 checksum How to use checksums |
cb5c714c409ff1e9a11c3cd83f56fc8c3a0eb172b9e8e7d5b331cbc19c79bd6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3
|
Release files / aiida_pytest-0.1.0a8-py3-none-any.whl
| Download URL | aiida_pytest-0.1.0a8-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20b42b3c9626cbf41fb5afe37534ba35790e9af4e4fdb6297950720bfecf4356
|
|
BLAKE2b-256 checksum How to use checksums |
3f57cdd61b1e7a9f52712e235fd23a84777bda3be422e51dae6527851e8fe6bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3
|