Skip to content

[prerelease] pytest-isort and if session is None: assert parent is None #9487

@The-Compiler

Description

@The-Compiler

Another one from #9415 - I don't quite understand what's going on and would like some help here.

When running the tests of pytest-isort, they fail with pytest 7.0.0rc1, but they fail in three different ways when bisecting things:

After 22dad53:

pytest_isort/__init__.py:67: in pytest_collect_file
    return IsortItem.from_parent(parent, fspath=path)
../../../proj/pytest/src/_pytest/nodes.py:587: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
../../../proj/pytest/src/_pytest/nodes.py:237: in from_parent
    return cls._create(parent=parent, **kw)
../../../proj/pytest/src/_pytest/nodes.py:128: in _create
    return super().__call__(*k, **kw)
pytest_isort/__init__.py:175: in __init__
    super(IsortItem, self).__init__(name=path, parent=parent, **kwargs)
../../../proj/pytest/src/_pytest/nodes.py:621: in __init__
    super().__init__(name, parent, config, session, nodeid=nodeid)
../../../proj/pytest/src/_pytest/nodes.py:549: in __init__
    path, fspath = _imply_path(path, fspath=fspath)
../../../proj/pytest/src/_pytest/nodes.py:100: in _imply_path
    raise ValueError(
E   ValueError: Path(local('/home/florian/tmp/pytest-bisect/pytest-isort/pytest_isort/__init__.py')) != <Session pytest-isort exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>
E   if both path and fspath are given they need to be equal

After d7b0e17:

pytest_isort/__init__.py:67: in pytest_collect_file
    return IsortItem.from_parent(parent, fspath=path)
../../../proj/pytest/src/_pytest/nodes.py:622: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
../../../proj/pytest/src/_pytest/nodes.py:254: in from_parent
    return cls._create(parent=parent, **kw)
../../../proj/pytest/src/_pytest/nodes.py:131: in _create
    return super().__call__(*k, **kw)
pytest_isort/__init__.py:175: in __init__
    super(IsortItem, self).__init__(name=path, parent=parent, **kwargs)
../../../proj/pytest/src/_pytest/nodes.py:671: in __init__
    super().__init__(
../../../proj/pytest/src/_pytest/nodes.py:576: in __init__
    path, fspath = _imply_path(path, fspath=fspath)
../../../proj/pytest/src/_pytest/nodes.py:112: in _imply_path
    assert fspath is not None
E   AssertionError
===================

After f87df9c (also needs 63899c7):

/home/florian/tmp/pytest-bisect/pytest-isort/tests/test_plugin.py:187: in test_init
    test_obj = IsortItem.from_parent(parent, fspath=path)
/home/florian/proj/pytest/src/_pytest/nodes.py:623: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
/home/florian/proj/pytest/src/_pytest/nodes.py:256: in from_parent
    return cls._create(parent=parent, **kw)
/home/florian/proj/pytest/src/_pytest/nodes.py:140: in _create
    return super().__call__(*k, **kw)
/home/florian/tmp/pytest-bisect/pytest-isort/pytest_isort/__init__.py:175: in __init__
    super(IsortItem, self).__init__(name=path, parent=parent, **kwargs)
/home/florian/proj/pytest/src/_pytest/nodes.py:676: in __init__
    super().__init__(
/home/florian/proj/pytest/src/_pytest/nodes.py:592: in __init__
    assert parent is not None
E   AssertionError

Note that you will need pytest-isort master (with stephrdev/pytest-isort#39 in).

This might be caused by something pytest-isort does (see its source), but honestly I'm pretty lost...

cc @RonnyPfannschmidt @bluetech @stephrdev @hroncok

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictype: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions