Git Product home page Git Product logo

aiida_pytest's Introduction

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.

Also, you need to create an empty .aiida in the folder where you want to run your tests. Then, you need to export AIIDA_PATH='.' to make sure aiida is using this config folder. This is to make sure that the tests create a local configuration (that will be destroyed after the test) instead of running in your main AiiDA configuration.

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.

aiida_pytest's People

Contributors

greschd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.