diff --git a/changelog/5975.deprecation.rst b/changelog/5975.deprecation.rst index fdee15a5aec..3845e3d17ae 100644 --- a/changelog/5975.deprecation.rst +++ b/changelog/5975.deprecation.rst @@ -3,4 +3,4 @@ Deprecate using direct constructors for ``Nodes``. Instead they are new constructed via ``Node.from_parent``. This painful transitional mechanism enables us to detangle the very intensely -entangled ``Node`` relationships. \ No newline at end of file +entangled ``Node`` relationships. diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index eb976058b24..b7c692da766 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -8,7 +8,8 @@ All constants defined in this module should be either PytestWarning instances or UnformattedWarning in case of warnings which need to format their messages. """ -from _pytest.warning_types import PytestDeprecationWarning, UnformattedWarning +from _pytest.warning_types import PytestDeprecationWarning +from _pytest.warning_types import UnformattedWarning # set of plugins which have been integrated into the core; we use this list to ignore # them during registration to avoid conflicts @@ -35,5 +36,7 @@ "as a keyword argument instead." ) -NODE_USE_FROM_PARENT = UnformattedWarning(PytestDeprecationWarning, - "direct construction of {name} has been deprecated, please use {name}.from_parent",) \ No newline at end of file +NODE_USE_FROM_PARENT = UnformattedWarning( + PytestDeprecationWarning, + "direct construction of {name} has been deprecated, please use {name}.from_parent", +) diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 3b5ee91bbe9..3e02f088f70 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -336,7 +336,9 @@ def collect(self): parser = doctest.DocTestParser() test = parser.get_doctest(text, globs, name, filename, 0) if test.examples: - yield DoctestItem.from_parent(self, name=test.name, runner=runner, dtest=test) + yield DoctestItem.from_parent( + self, name=test.name, runner=runner, dtest=test + ) def _check_all_skipped(test): @@ -432,7 +434,9 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen): for test in finder.find(module, module.__name__): if test.examples: # skip empty doctests - yield DoctestItem.from_parent(self, name=test.name, runner=runner, dtest=test) + yield DoctestItem.from_parent( + self, name=test.name, runner=runner, dtest=test + ) def _setup_fixtures(doctest_item): diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 9abcf0c85cc..970eded3ebb 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -2,7 +2,6 @@ import warnings from contextlib import contextmanager from functools import lru_cache -from functools import wraps from typing import Any from typing import Dict from typing import List @@ -14,11 +13,11 @@ import _pytest._code from _pytest.compat import getfslineno +from _pytest.deprecated import NODE_USE_FROM_PARENT from _pytest.mark.structures import Mark from _pytest.mark.structures import MarkDecorator from _pytest.mark.structures import NodeKeywords from _pytest.outcomes import fail -from _pytest.deprecated import NODE_USE_FROM_PARENT if False: # TYPE_CHECKING # Imported here due to circular import. @@ -72,10 +71,7 @@ class NodeMeta(type): def __call__(self, *k, **kw): if not self.__in_named_ctor: - warnings.warn( - NODE_USE_FROM_PARENT.format(name=self.__name__), - stacklevel=3, - ) + warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=3) return self._create(*k, **kw) @contextmanager