===============
pytest-molecule
===============
.. image:: https://img.shields.io/pypi/v/pytest-molecule.svg
:target: https://pypi.org/project/pytest-molecule
:alt: PyPI version
.. image:: https://img.shields.io/pypi/pyversions/pytest-molecule.svg
:target: https://pypi.org/project/pytest-molecule
:alt: Python versions
.. image:: https://zuul-ci.org/gated.svg
:target: https://dashboard.zuul.ansible.com/t/ansible/builds?project=pycontribs/selinux
:alt: See Build Status on Zuul CI
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black
:alt: 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:
.. code-block:: shell
# 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
If the molecule scenario does not contain information about the driver, the
test associated with it gets a ``no_driver`` mark.
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 ``None`` but you
can choose marks like ``skip`` or ``xfail``.
The plugin adds ``--skip-no-git-change`` option which an be used to skip tests
on unchanged roles according to ``git diff`` result and thus can only be used
only when running pytest inside a git repository. It takes one argument and old
refspec used as a reference. For instance calling:
``pytest --skip-no-git-change HEAD^`` will result in molecule of roles that
weren't changed in the last commit being skipped.
Using xfail and skip markers
----------------------------
If you need to skip or ignore a particular scenario, just add either ``xfail``
or ``skip`` to markers list inside its config file.
.. code-block:: yaml
markers:
- xfail # broken scenario, pytest will run it but ignore the result
Installation
------------
You can install "pytest-molecule" via pip_ from PyPI_:
.. code-block:: shell
$ 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.
.. _`MIT`: http://opensource.org/licenses/MIT
.. _`file an issue`: https://github.com/pycontribs/pytest-molecule/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
.. _markers: http://doc.pytest.org/en/latest/example/markers.html
Raw data
{
"_id": null,
"home_page": "https://github.com/LegenJCdary/pytest-molecule",
"name": "pytest-molecule-JC",
"maintainer": "Jakub Wierzbowski",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "jakub.wierzbowski@aptiv.com",
"keywords": "ansible,roles,testing,molecule,pytest,plugin",
"author": "Jakub Wierzbowski",
"author_email": "jakub.wierzbowski@aptiv.com",
"download_url": "https://files.pythonhosted.org/packages/48/be/273b8f7d246dfc9103994b73c63399d674cc3929973328cfc826277feaa9/pytest_molecule_JC-2.0.0.post2.tar.gz",
"platform": null,
"description": "===============\npytest-molecule\n===============\n\n.. image:: https://img.shields.io/pypi/v/pytest-molecule.svg\n :target: https://pypi.org/project/pytest-molecule\n :alt: PyPI version\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-molecule.svg\n :target: https://pypi.org/project/pytest-molecule\n :alt: Python versions\n\n.. image:: https://zuul-ci.org/gated.svg\n :target: https://dashboard.zuul.ansible.com/t/ansible/builds?project=pycontribs/selinux\n :alt: See Build Status on Zuul CI\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/python/black\n :alt: Python Black Code Style\n\nPyTest Molecule Plugin :: auto detects and runs molecule tests\n\n----\n\nThis plugin enables pytest discovery of all ``molecule.yml`` files inside the\ncodebase and runs them as pytest tests.\n\nOnce you install pytest-molecule you should be able to just run ``pytest`` in\norder to run molecule on all roles and scenarios.\n\nOptionally you can define ``MOLECULE_OPTS`` for passing extra parameters to\neach molecule call.\n\nDiscovered tests do have molecule ``driver`` and ``platforms`` added as\nmarkers_, so you can selectively limit which test types to run:\n\n.. code-block:: shell\n\n # Lists all tests that uses docker\n $ pytest --collect-only -m docker\n\n # Runs scenarios with platform named centos7 and delegated driver:\n $ pytest -m delegated -m centos7\n\nIf the molecule scenario does not contain information about the driver, the\ntest associated with it gets a ``no_driver`` mark.\n\nPlease note that at this moment molecule will run the entire scenario if the\nmarkers are platforms, this is not *yet* a way to limit which platforms are\nexecuted inside a specific scenario.\n\nAll tests are added the ``molecule`` marker.\n\nThis plugin also adds a new pytest option named\n``--molecule-unavailable-driver=skip`` which can be used to tell it what to do\nwhen molecule drivers are not loading. Current default is ``None`` but you\ncan choose marks like ``skip`` or ``xfail``.\n\nThe plugin adds ``--skip-no-git-change`` option which an be used to skip tests\non unchanged roles according to ``git diff`` result and thus can only be used\nonly when running pytest inside a git repository. It takes one argument and old\nrefspec used as a reference. For instance calling:\n``pytest --skip-no-git-change HEAD^`` will result in molecule of roles that\nweren't changed in the last commit being skipped.\n\n\nUsing xfail and skip markers\n----------------------------\n\nIf you need to skip or ignore a particular scenario, just add either ``xfail``\nor ``skip`` to markers list inside its config file.\n\n.. code-block:: yaml\n\n markers:\n - xfail # broken scenario, pytest will run it but ignore the result\n\nInstallation\n------------\n\nYou can install \"pytest-molecule\" via pip_ from PyPI_:\n\n.. code-block:: shell\n\n $ PIP_NO_BUILD_ISOLATION=false pip install pytest-molecule\n\n``PIP_NO_BUILD_ISOLATION`` is needed only on ancient python distributions to\nworkaround https://github.com/pypa/pip/issues/5229\n\nContributing\n------------\nContributions are very welcome. Tests can be run with tox_, please ensure\nthe coverage at least stays the same before you submit a pull request.\n\nLicense\n-------\n\nDistributed under the terms of the MIT_ license, \"pytest-molecule\" is free\nand open source software\n\n\nIssues\n------\n\nIf you encounter any problems, please `file an issue`_ along with a detailed\ndescription.\n\n.. _`MIT`: http://opensource.org/licenses/MIT\n.. _`file an issue`: https://github.com/pycontribs/pytest-molecule/issues\n.. _`pytest`: https://github.com/pytest-dev/pytest\n.. _`tox`: https://tox.readthedocs.io/en/latest/\n.. _`pip`: https://pypi.org/project/pip/\n.. _`PyPI`: https://pypi.org/project\n.. _markers: http://doc.pytest.org/en/latest/example/markers.html\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "PyTest Molecule Plugin :: discover and run molecule tests",
"version": "2.0.0.post2",
"project_urls": {
"Homepage": "https://github.com/LegenJCdary/pytest-molecule"
},
"split_keywords": [
"ansible",
"roles",
"testing",
"molecule",
"pytest",
"plugin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2200b60bc34f39e0cd5a9f0daba7eba82dc3326a25c04550b1cf8c299c274779",
"md5": "2a5085b98e4bce4628f55091e45d2a24",
"sha256": "ffd3c07411c82f2b038b355ba6a02df7373db9e1b3be0bee947827f28c1e226b"
},
"downloads": -1,
"filename": "pytest_molecule_JC-2.0.0.post2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2a5085b98e4bce4628f55091e45d2a24",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8444,
"upload_time": "2023-07-18T13:25:47",
"upload_time_iso_8601": "2023-07-18T13:25:47.081820Z",
"url": "https://files.pythonhosted.org/packages/22/00/b60bc34f39e0cd5a9f0daba7eba82dc3326a25c04550b1cf8c299c274779/pytest_molecule_JC-2.0.0.post2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "48be273b8f7d246dfc9103994b73c63399d674cc3929973328cfc826277feaa9",
"md5": "07670495985b6e75d8991f81a160fc52",
"sha256": "0a834ecb66be677781574591a406c6429a2616cee4c34b273deff6e1863c3172"
},
"downloads": -1,
"filename": "pytest_molecule_JC-2.0.0.post2.tar.gz",
"has_sig": false,
"md5_digest": "07670495985b6e75d8991f81a160fc52",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 19174,
"upload_time": "2023-07-18T13:25:48",
"upload_time_iso_8601": "2023-07-18T13:25:48.210178Z",
"url": "https://files.pythonhosted.org/packages/48/be/273b8f7d246dfc9103994b73c63399d674cc3929973328cfc826277feaa9/pytest_molecule_JC-2.0.0.post2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-18 13:25:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LegenJCdary",
"github_project": "pytest-molecule",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-molecule-jc"
}