Metadata-Version: 2.1
Name: pytest-molecule-JC
Version: 2.0.0.post1
Summary: PyTest Molecule Plugin :: discover and run molecule tests
Home-page: https://github.com/LegenJCdary/pytest-molecule
Author: Jakub Wierzbowski
Author-email: jakub.wierzbowski@aptiv.com
Maintainer: Jakub Wierzbowski
Maintainer-email: jakub.wierzbowski@aptiv.com
License: MIT
Keywords: ansible,roles,testing,molecule,pytest,plugin
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: molecule (>=3.6.0)
Requires-Dist: pytest-html
Requires-Dist: pytest (>=7.0.0)
Provides-Extra: ansi
Requires-Dist: ansi2html ; extra == 'ansi'
Provides-Extra: docker
Requires-Dist: molecule-docker ; extra == 'docker'
Requires-Dist: paramiko (>=2.5.0) ; extra == 'docker'
Provides-Extra: podman
Requires-Dist: molecule-podman ; extra == 'podman'
Provides-Extra: vagrant
Requires-Dist: molecule-vagrant ; extra == 'vagrant'

===============
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


