Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterparentnodeids removed from pytest #668

Closed
The-Compiler opened this issue Jan 10, 2024 · 1 comment
Closed

iterparentnodeids removed from pytest #668

The-Compiler opened this issue Jan 10, 2024 · 1 comment
Assignees

Comments

@The-Compiler
Copy link
Member

The-Compiler commented Jan 10, 2024

Running against the current pytest main branch results in:

File "/__w/qutebrowser/qutebrowser/.tox/bleeding-qt5/lib/python3.11/site-packages/pytest_bdd/__init__.py", line 4, in <module>
    from pytest_bdd.scenario import scenario, scenarios
  File "/__w/qutebrowser/qutebrowser/.tox/bleeding-qt5/lib/python3.11/site-packages/_pytest/assertion/rewrite.py", line 175, in exec_module
    exec(co, module.__dict__)
  File "/__w/qutebrowser/qutebrowser/.tox/bleeding-qt5/lib/python3.11/site-packages/pytest_bdd/scenario.py", line 23, in <module>
    from _pytest.nodes import iterparentnodeids
ImportError: cannot import name 'iterparentnodeids' from '_pytest.nodes' (/__w/qutebrowser/qutebrowser/.tox/bleeding-qt5/lib/python3.11/site-packages/_pytest/nodes.py)

due to:

Relevant changelog entry:

  • The _pytest.nodes.iterparentnodeids() function is removed without replacement. Prefer to traverse the node hierarchy itself instead. If you really need to, copy the function from the previous pytest release.

Relevant code from before it was removed (with SEP = "/"):

def iterparentnodeids(nodeid: str) -> Iterator[str]:
    """Return the parent node IDs of a given node ID, inclusive.
    For the node ID
        "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"
    the result would be
        ""
        "testing"
        "testing/code"
        "testing/code/test_excinfo.py"
        "testing/code/test_excinfo.py::TestFormattedExcinfo"
        "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"
    Note that / components are only considered until the first ::.
    """
    pos = 0
    first_colons: Optional[int] = nodeid.find("::")
    if first_colons == -1:
        first_colons = None
    # The root Session node - always present.
    yield ""
    # Eagerly consume SEP parts until first colons.
    while True:
        at = nodeid.find(SEP, pos, first_colons)
        if at == -1:
            break
        if at > 0:
            yield nodeid[:at]
        pos = at + len(SEP)
    # Eagerly consume :: parts.
    while True:
        at = nodeid.find("::", pos)
        if at == -1:
            break
        if at > 0:
            yield nodeid[:at]
        pos = at + len("::")
    # The node ID itself.
    if nodeid:
        yield nodeid
@youtux youtux self-assigned this Jan 21, 2024
@youtux
Copy link
Contributor

youtux commented Jan 21, 2024

Thanks for reporting this, fixed in #666

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants