def pytest_itemcollected(item: Item) -> None:
    """Mark tests as thread unsafe if they make use of fixtures that doesn't play well across threads."""
    fixtures: tuple[str, ...] = getattr(item, 'fixturenames', ())
    if any(fixture in fixtures for fixture in _thread_unsafe_fixtures):
        item.add_marker('thread_unsafe')
Mark tests as thread unsafe if they make use of fixtures that doesn't play well across threads.
tests/conftest.py