Skip to content

Tests fail with pytest 9.1: _pytest.monkeypatch.notset removed #6071

Description

@hrnciar

Flask's test suite imports the private notset sentinel from _pytest.monkeypatch in both tests/conftest.py and tests/test_cli.py. pytest 9.1 removed this attribute, moving it to _pytest.compat.NOTSET. This causes a collection-time crash — no tests can run at all.

Reproducing

pip install -e . pytest==9.1.1
pytest tests/
tests/test_cli.py:14: in <module>
    from _pytest.monkeypatch import notset
E   ImportError: cannot import name 'notset' from '_pytest.monkeypatch'

Even after fixing test_cli.py, every test fails because tests/conftest.py accesses monkeypatch.notset as a module attribute in the _standard_os_environ session fixture:

tests/conftest.py:19: AttributeError: module '_pytest.monkeypatch' has no attribute 'notset'

Expected Behavior

The test suite should work with pytest 9.1+.

Environment:

Python version: 3.15.0b2
Flask version: 3.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions