Skip to content

Commit 672e8b1

Browse files
fix fixture lookup triggering the TerminalWriter.writer deprecation
1 parent e1b3a68 commit 672e8b1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/_pytest/fixtures.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,11 @@ def parsefactories(self, node_or_obj, nodeid=NOTSET, unittest=False):
14131413
for name in dir(holderobj):
14141414
# The attribute can be an arbitrary descriptor, so the attribute
14151415
# access below can raise. safe_getatt() ignores such exceptions.
1416+
# additionally properties are ignored by default to avoid triggering warnings
1417+
if not isinstance(holderobj, type) and isinstance(
1418+
safe_getattr(holderobj.__class__, name, None), property
1419+
):
1420+
continue
14161421
obj = safe_getattr(holderobj, name, None)
14171422
marker = getfixturemarker(obj)
14181423
if not isinstance(marker, FixtureFunctionMarker):

src/_pytest/terminal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def writer(self) -> TerminalWriter:
288288
pytest.PytestDeprecationWarning(
289289
"TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.\n"
290290
"See https://docs.pytest.org/en/latest/deprecations.html#terminalreporter-writer for more information."
291-
)
291+
),
292+
stacklevel=2,
292293
)
293294
return self._tw
294295

0 commit comments

Comments
 (0)