Skip to content

Commit 904e946

Browse files
committed
Document that the extra "::()" is stripped from old style node ids of
class methods.
1 parent 16ded0d commit 904e946

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

doc/src/names.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ look like:
3939

4040
.. literalinclude:: ../examples/nodeid.out
4141

42+
.. note::
43+
Old versions of pytest used to include an extra "()" component to
44+
the node ids of methods of test classes. This has been
45+
`removed in pytest 4.0.0`__. pytest-dependency strips this
46+
if present. Thus, when referencing dependencies, the new style
47+
node ids as described above may (and must) be used, regardless of
48+
the pytest version.
49+
50+
.. __: https://docs.pytest.org/en/latest/changelog.html#pytest-4-0-0-2018-11-13
51+
4252
References and scope
4353
--------------------
4454

pytest_dependency.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def __init__(self, scope):
7272

7373
def addResult(self, item, name, rep):
7474
if not name:
75+
# Old versions of pytest used to add an extra "::()" to
76+
# the node ids of class methods to denote the class
77+
# instance. This has been removed in pytest 4.0.0.
7578
nodeid = item.nodeid.replace("::()::", "::")
7679
if self.scope == 'session' or self.scope == 'package':
7780
name = nodeid

0 commit comments

Comments
 (0)