Skip to content

Getting an uninitialized error when using pytest_deselected hook #13149

@pfunk1978

Description

@pfunk1978

When using the included hook. I'm getting the following error:

INTERNALERROR>     config.hook.pytest_deselected(do_not_run)
INTERNALERROR> TypeError: HookCaller.__call__() takes 1 positional argument but 2 were given

I'm not sure if I was supposed to initialize something somewhere. I didn't see anything in the docs about it.

Error produced from the following code:

def pytest_configure(config):
    config.addinivalue_line(
        "markers",
        "requirement(jira_issue): The jira issue that is being tested"
    )


def _is_wanted_test(item, run_tags) -> bool:
    maybe_wanted = list(item.iter_markers(name="requirment"))
    if maybe_wanted:
        return (maybe_wanted[0].args[0] in run_tags)
    return False


def pytest_collection_modifyitems(session, config, items):
    req_tags_str = config.getoption("--requirements")
    if req_tags_str:
        req_tags = [i.strip() for i in req_tags_str.split(",")]
        do_not_run = filter(
            lambda item: not _is_wanted_test(item, req_tags),
            items
        )
        config.hook.pytest_deselected(do_not_run)

pytest 8.3.4
os Fedora 41
pip list:

allure-pytest         2.13.5
allure-python-commons 2.13.5
annotated-types       0.7.0
argon2-cffi           23.1.0
argon2-cffi-bindings  21.2.0
attrs                 23.2.0
bitarray              2.9.3
bitstring             4.2.3
bitstruct             8.19.0
certifi               2024.2.2
cffi                  1.16.0
charset-normalizer    3.3.2
click                 8.1.8
colorama              0.4.6
cryptography          42.0.7
dotmap                1.3.30
enum-compat           0.0.3
hypothesis            6.102.4
idna                  3.7
iniconfig             2.0.0
kyber                 0.1.0
liboqs                0.9.1
markdown-it-py        3.0.0
mdurl                 0.1.2
ntplib                0.4.0
numpy                 2.2.1
orjson                3.10.14
packaging             24.0
pip                   24.3.1
pluggy                1.5.0
protobuf              5.29.1
pyasn1                0.6.1
pyasn1_modules        0.4.1
pycparser             2.22
pycryptodome          3.21.0
pycryptodomex         3.21.0
pydantic              2.10.5
pydantic_core         2.27.2
Pygments              2.19.1
pyparsing             3.2.0
pytest                8.3.4
pytest-jira-xray      0.8.11
requests              2.32.2
rich                  13.9.4
shellingham           1.5.4
sortedcontainers      2.4.0
typer                 0.9.4
types-zxcvbn          4.4.1.20240106
typing_extensions     4.12.2
urllib3               2.2.1
zxcvbn                4.4.28

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions