markus
markus copied to clipboard
add pytest fixture
Everyone that I've talked to that uses Markus is also using pytest and has to add something like this to their conftest.py
:
from markus.testing import MetricsMock
@pytest.fixture
def metricsmock():
with MetricsMock() as mm:
yield mm
That seems silly. We should add it to Markus proper and document usage of the fixture.
@jwhitlock suggests I read https://docs.pytest.org/en/7.4.x/how-to/writing_plugins.html .
I like the idea! There's a list of packages providing plugins at https://docs.pytest.org/en/7.4.x/how-to/plugins.html, you can see how they implemented their plugin to provide fixtures.
I think it is as simple as adding that code to https://github.com/willkg/markus/blob/main/src/markus/pytest_plugin.py.