Sobes.tech
Middle

Have you customized the marking in pytest?

sobes.tech AI

Answer from AI

Yes, I customized the markers in pytest for grouping and managing tests according to my criteria. For example, you can define a custom marker in the pytest.ini file:

[pytest]
markers =
    slow: marks slow tests
    api: tests related to API

Then, use these markers in your tests:

import pytest

@pytest.mark.slow
def test_long_running():
    assert True

@pytest.mark.api
def test_api_call():
    assert True

This allows you to run tests selectively, for example, pytest -m slow will run only the slow tests. You can also create more complex custom markers with parameters and use them to configure test behavior.