Skip to content

Commit de835f2

Browse files
fixup: unittest argument implication deprecation
1 parent 15619bf commit de835f2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/_pytest/deprecated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
NODE_IMPLIED_ARG = UnformattedWarning(
6868
PytestDeprecationWarning,
69-
"implying{type.__name__}.{arg} from parent.{arg} has been deprecated\n"
69+
"implying {type.__name__}.{arg} from parent.{arg} has been deprecated\n"
7070
"please use the Node.from_parent to have them be implied by the superclass named ctors",
7171
)
7272

testing/test_nodes.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,34 @@ def test_node_from_parent_disallowed_arguments() -> None:
3939
nodes.Node.from_parent(None, name="none", config=None) # type: ignore[arg-type]
4040

4141

42+
@pytest.mark.parametrize("absent_arg", ["nodeid", "config", "session", "fs_path"])
43+
def test_node_warns_implied_ctor_args(pytester, absent_arg):
44+
config = pytester.parseconfigure()
45+
from _pytest.main import Session
46+
47+
session = Session.from_config(config)
48+
49+
args = dict(
50+
name="test",
51+
nodeid="test",
52+
session=session,
53+
config=session.config,
54+
fs_path=session.fs_path,
55+
)
56+
del args[absent_arg]
57+
58+
with pytest.warns(
59+
PytestWarning,
60+
match=fr"implying Node.{absent_arg} from parent.{absent_arg} has been deprecated\n"
61+
"please use the Node.from_parent to have them be implied by the superclass named ctors",
62+
):
63+
nodes.Node._create(parent=session, **args)
64+
65+
66+
def test_fspath_warns():
67+
pass
68+
69+
4270
@pytest.mark.parametrize(
4371
"warn_type, msg", [(DeprecationWarning, "deprecated"), (PytestWarning, "pytest")]
4472
)

0 commit comments

Comments
 (0)