Skip to content

Commit

Permalink
fixup! test_node_from_parent_kwonly
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Nov 5, 2020
1 parent dfa465f commit 72515c8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions testing/test_nodes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest
from _pytest import nodes
from _pytest.compat import TYPE_CHECKING
Expand Down Expand Up @@ -30,14 +32,22 @@ def test_node_from_parent_kwonly(request: "FixtureRequest") -> None:
This can lead to confusing TypeErrors, but is kept like that for (backward) compatibility."""
session = request.session
if sys.version_info >= (3, 10):
prefix_name = "nodes.Node."
else:
prefix_name = ""
with pytest.raises(
TypeError,
match=r"__init__\(\) missing 1 required positional argument: 'name'"
match=r"^{}__init__\(\) missing 1 required positional argument: 'name'$".format(
prefix_name
),
):
nodes.Node.from_parent(session)
with pytest.raises(
TypeError,
match=r'^from_parent\(\) takes 2 positional arguments but 3 were given$'
match=r'^{}from_parent\(\) takes 2 positional arguments but 3 were given$'.format(
prefix_name
)
):
nodes.Node.from_parent(session, "myname") # type: ignore[call-arg]
node = nodes.Node.from_parent(session, name="myname")
Expand Down

0 comments on commit 72515c8

Please sign in to comment.