Skip to content

Broken compatibility with pytest<7 (pytest.Parser type annotation) #755

@martinhoyer

Description

@martinhoyer

The parser annotation in plugin.py introduced in 10.0 does not work with pytest 6.

def pytest_addoption(parser: pytest.Parser) -> None:

pytest.Parser is only available from pytest 7.0.0

>>> from testinfra import plugin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/testinfra/plugin.py", line 40, in <module>
    def pytest_addoption(parser: pytest.Parser) -> None:
AttributeError: module 'pytest' has no attribute 'Parser'

While specifying minimal pytest version would be a solution, I would rather recommend finding another solution, as RHEL-9/Alma Linux 9/CentOS Stream 9 are running pytest 6 (and Python 3.9).

I'd be happy to help with finding a solution, should you decide to keep pytest 6 compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions