summaryrefslogtreecommitdiff
path: root/testing/deprecated_test.py
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2019-10-16 21:52:04 +0200
committerRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2019-11-23 21:54:11 +0100
commitc99c7d0f95170a5e308ed6c37e63b2d90794a4f9 (patch)
tree69f05b6ec107f6a979c3b2c037aa598e61da58d9 /testing/deprecated_test.py
parent886b8d27c669c6a65488192f75299a7cb9e1ab52 (diff)
downloadpytest-c99c7d0f95170a5e308ed6c37e63b2d90794a4f9.tar.gz
deprecate direct node construction and introduce Node.from_parent
Diffstat (limited to 'testing/deprecated_test.py')
-rw-r--r--testing/deprecated_test.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py
index 5390d038d..59cb69a00 100644
--- a/testing/deprecated_test.py
+++ b/testing/deprecated_test.py
@@ -1,5 +1,8 @@
+import inspect
+
import pytest
from _pytest import deprecated
+from _pytest import nodes
@pytest.mark.filterwarnings("default")
@@ -73,3 +76,17 @@ def test_warn_about_imminent_junit_family_default_change(testdir, junit_family):
result.stdout.no_fnmatch_line(warning_msg)
else:
result.stdout.fnmatch_lines([warning_msg])
+
+
+def test_node_direct_ctor_warning():
+ class MockConfig:
+ pass
+
+ ms = MockConfig()
+ with pytest.warns(
+ DeprecationWarning,
+ match="direct construction of .* has been deprecated, please use .*.from_parent",
+ ) as w:
+ nodes.Node(name="test", config=ms, session=ms, nodeid="None")
+ assert w[0].lineno == inspect.currentframe().f_lineno - 1
+ assert w[0].filename == __file__