Skip to content

Commit f87df9c

Browse files
bluetechThe-Compilernicoddemus
authored
nodes: keep plugins which subclass Item, File working for a bit more (#9279)
* nodes: keep plugins which subclass Item, File working for a bit more Fix #8435. * Update src/_pytest/nodes.py Co-authored-by: Bruno Oliveira <[email protected]> Co-authored-by: Florian Bruhin <[email protected]> Co-authored-by: Bruno Oliveira <[email protected]>
1 parent eb6c449 commit f87df9c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/_pytest/nodes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,13 @@ def __init__(
669669
nodeid: Optional[str] = None,
670670
**kw,
671671
) -> None:
672+
# The first two arguments are intentionally passed positionally,
673+
# to keep plugins who define a node type which inherits from
674+
# (pytest.Item, pytest.File) working (see issue #8435).
675+
# They can be made kwargs when the deprecation above is done.
672676
super().__init__(
673-
name=name,
674-
parent=parent,
677+
name,
678+
parent,
675679
config=config,
676680
session=session,
677681
nodeid=nodeid,

testing/test_nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_subclassing_both_item_and_collector_deprecated(
7171
),
7272
):
7373

74-
class SoWrong(nodes.File, nodes.Item):
74+
class SoWrong(nodes.Item, nodes.File):
7575
def __init__(self, fspath, parent):
7676
"""Legacy ctor with legacy call # don't wana see"""
7777
super().__init__(fspath, parent)

0 commit comments

Comments
 (0)