Skip to content

Commit 72515c8

Browse files
committed
fixup! test_node_from_parent_kwonly
1 parent dfa465f commit 72515c8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

testing/test_nodes.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
import pytest
24
from _pytest import nodes
35
from _pytest.compat import TYPE_CHECKING
@@ -30,14 +32,22 @@ def test_node_from_parent_kwonly(request: "FixtureRequest") -> None:
3032
3133
This can lead to confusing TypeErrors, but is kept like that for (backward) compatibility."""
3234
session = request.session
35+
if sys.version_info >= (3, 10):
36+
prefix_name = "nodes.Node."
37+
else:
38+
prefix_name = ""
3339
with pytest.raises(
3440
TypeError,
35-
match=r"__init__\(\) missing 1 required positional argument: 'name'"
41+
match=r"^{}__init__\(\) missing 1 required positional argument: 'name'$".format(
42+
prefix_name
43+
),
3644
):
3745
nodes.Node.from_parent(session)
3846
with pytest.raises(
3947
TypeError,
40-
match=r'^from_parent\(\) takes 2 positional arguments but 3 were given$'
48+
match=r'^{}from_parent\(\) takes 2 positional arguments but 3 were given$'.format(
49+
prefix_name
50+
)
4151
):
4252
nodes.Node.from_parent(session, "myname") # type: ignore[call-arg]
4353
node = nodes.Node.from_parent(session, name="myname")

0 commit comments

Comments
 (0)