def test_node_direct_construction_deprecated() -> None: with pytest.raises( OutcomeException, match= ("Direct construction of _pytest.nodes.Node has been deprecated, please " "use _pytest.nodes.Node.from_parent.\nSee " "https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent" " for more details."), ): nodes.Node(None, session=None) # type: ignore[arg-type]
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__