From ddbb998aed82c599886d31b3a48930042b623463 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 20 Apr 2022 19:07:10 +0300 Subject: [PATCH] [7.1.x] Increase stacklevel to point at user's code --- changelog/9869.bugfix.rst | 2 ++ src/_pytest/nodes.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/9869.bugfix.rst diff --git a/changelog/9869.bugfix.rst b/changelog/9869.bugfix.rst new file mode 100644 index 00000000000..9761d7f161b --- /dev/null +++ b/changelog/9869.bugfix.rst @@ -0,0 +1,2 @@ +Increase ``stacklevel`` for the ``NODE_CTOR_FSPATH_ARG`` deprecation to point to the +user's code, not pytest. diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index e49c1b003e0..1a168043a4f 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -111,7 +111,7 @@ def _imply_path( NODE_CTOR_FSPATH_ARG.format( node_type_name=node_type.__name__, ), - stacklevel=3, + stacklevel=6, ) if path is not None: if fspath is not None: