Skip to main content

PyTest Molecule Plugin :: discover and run molecule tests

Project description

PyPI version Python versions See Build Status on Travis CI Python Black Code Style

PyTest Molecule Plugin :: auto detects and runs molecule tests


This plugin enables pytest discovery of all molecule.yml files inside the codebase and runs them as pytest tests.

Once you install pytest-molecule you should be able to just run pytest in order to run molecule on all roles and scenarios.

Optionally you can define MOLECULE_OPTS for passing extra parameters to each molecule call.

Discovered tests do have molecule driver and platforms added as markers, so you can selectively limit which test types to run:

# Lists all tests that uses docker
$ pytest --collect-only -m docker

# Runs scenarios with platform named centos7 and delegated driver:
$ pytest -m delegated -m centos7

Please note that at this moment molecule will run the entire scenario if the markers are platforms, this is not yet a way to limit which platforms are executed inside a specific scenario.

All tests are added the molecule marker.

This plugin also adds a new pytest option named --molecule-unavailable-driver=skip which can be used to tell it what to do when molecule drivers are not loading. Current default is skip but you can choose other marks like xfail or empty string if you want to disable this functionality.

Current implementation of this feature validates only docker and delegated drivers. Due to the potential destructive nature of delegated driver, scenarios running it will run only if Ansible detects one of the following variables as defined: zuul, use_for_testing.

Installation

You can install “pytest-molecule” via pip from PyPI:

$ PIP_NO_BUILD_ISOLATION=false pip install pytest-molecule

PIP_NO_BUILD_ISOLATION is needed only on ancient python distributions to workaround https://github.com/pypa/pip/issues/5229

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, “pytest-molecule” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-molecule-1.2.1rc1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_molecule-1.2.1rc1-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-molecule-1.2.1rc1.tar.gz.

File metadata

  • Download URL: pytest-molecule-1.2.1rc1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for pytest-molecule-1.2.1rc1.tar.gz
Algorithm Hash digest
SHA256 6f90684821d155c832454cdb4bf64b3cb51ffcac66c0a8a7dfe5977b3b5cde87
MD5 4905157aa4c029d51004ccf2bbb13845
BLAKE2b-256 debd1e824a10be91470ca18a79b76b26bdf92ac5e665c57abecb20397c571f5e

See more details on using hashes here.

File details

Details for the file pytest_molecule-1.2.1rc1-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_molecule-1.2.1rc1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for pytest_molecule-1.2.1rc1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bc01683c747e8a67bd31239dd70a569c3b8ca0ffd57622abe98af7a4d36e804f
MD5 a0e17b157ab29f98dcfbd4b3159fbd0e
BLAKE2b-256 e0de6c9e98f928039195aac6dba71685870789c96da3f913b3f73a39141b3739

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page