![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
pytest-coveragemarkers
Advanced tools
Using pytest markers to track functional coverage and filtering of tests
.. image:: https://img.shields.io/badge/security-bandit-yellow.svg :target: https://github.com/PyCQA/bandit :alt: Security Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black
Using pytest markers to track functional coverage and filtering of tests
This pytest
_ plugin was generated with Cookiecutter
_ along with @hackebrot
's cookiecutter-pytest-plugin
template.
You can install "pytest-coveragemarkers" from PyPI
_::
$ pip install pytest-coveragemarkers
# or
$ poetry add pytest-coveragemarkers
Step 1: Define your coverage markers yaml.
Using the format:
.. code-block:: yaml
markers: - name: <marker_name> allowed: - <marker_value_1> - <marker_value_2> - name: <marker2_name> allowed: - <marker2_value_1> - <marker2_value_2>
Then decorate your tests with them
.. code-block:: python
import pytest
@pytest.mark.marker_name(['value1', 'value2'])
@pytest.mark.marker2_name(['value1', 'value2'])
def test_x():
...
@pytest.mark.marker2_name(['value1', 'value2'])
def test_y():
...
Then when the tests are executed with
.. code-block:: shell
pytest --json-report --markers-location=/full/path/to/coverage_markers.yml
Then the JSON Test Report output from the test execution contains:
.. code-block:: json
"tests": [
{
"nodeid": "...",
"metadata": {
"cov_markers": {
"marker_name": {
"value1": true,
"value2": true
},
"marker2_name": {
"value1": true,
"value2": true
}
}
}
},
...
]
This can then be used to generate test coverage details based on the coverage markers. A nice demo will be produced to give examples of usage.
But wait there is another benefit:
We can filter tests for execution based on their coverage markers
.. code-block:: shell
pytest \
--filter='"value1" in marker_name' \
--json-report \
--markers-location=/full/path/to/coverage_markers.yml
The above command run against the tests defined above would select 'test_x' and deselect 'test_y' for execution
Other examples of filters are:
.. code-block: shell
'("value1" in marker_name) or ("value2" in marker_name)'
You can also supply the path to a file containing your filter. Use argument --filter-location or key FilterLocation in the pytest.ini file.
Coverage markers can be detailed as mandatory by including the mandatory attribute.
E.g.
.. code-block:: yaml
markers: - name: <marker_name> mandatory: True allowed: - <marker_value_1> - <marker_value_2>
Coverage markers can be detailed as a dependency on another marker. This ensures that if a marker is specified all dependencies of this marker in the chain must also be specified.
E.g.
.. code-block:: yaml
markers: - name: <marker_name> dependents: - <marker_name...> - <marker_name...> allowed: - <marker_value_1> - <marker_value_2>
The arguments supplied to Coverage Markers can follow multiple formats which allows the user to define the format that best suites them.
E.g.
.. code-block:: python
import pytest
@pytest.mark.marker_1('value1') # single string argument
@pytest.mark.marker_2('value1', 'value2') # multiple string arguments
@pytest.mark.marker_3(['value1', 'value2']) # list of arguments
@pytest.mark.marker_4(('value1', 'value2')) # tuple of arguments
def test_x():
...
Nox is used by this project to execute all tests. To run a specific set of tests execute the below line::
$ poetry run nox -s <session_name>
Where session_name can be one of the following
.. list-table:: Nox Sessions :widths: 25 75 :header-rows: 1
pytest_docs
_ talks about using markers to set metadata on tests and use the markers to select required tests for execution.To build the docs run::
poetry run mkdocs serve
Distributed under the terms of the MIT
_ license, "pytest-coveragemarkers" is free and open source software
If you encounter any problems, please file an issue
_ along with a detailed description.
.. _Cookiecutter
: https://github.com/audreyr/cookiecutter
.. _@hackebrot
: https://github.com/hackebrot
.. _MIT
: http://opensource.org/licenses/MIT
.. _BSD-3
: http://opensource.org/licenses/BSD-3-Clause
.. _GNU GPL v3.0
: http://www.gnu.org/licenses/gpl-3.0.txt
.. _Apache Software License 2.0
: http://www.apache.org/licenses/LICENSE-2.0
.. _cookiecutter-pytest-plugin
: https://github.com/pytest-dev/cookiecutter-pytest-plugin
.. _file an issue
: https://github.com/Gleams99/pytest-coveragemarkers/issues
.. _pytest
: https://github.com/pytest-dev/pytest
.. _nox
: https://nox.thea.codes/en/stable/
.. _pip
: https://pypi.org/project/pip/
.. _PyPI
: https://pypi.org/project
.. _pytest_docs
: https://docs.pytest.org/en/7.1.x/how-to/mark.html?highlight=slow
FAQs
Using pytest markers to track functional coverage and filtering of tests
We found that pytest-coveragemarkers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.