src/_pytest/deprecated.py stores 11 deprecations as module-level instances (PRIVATE, CALLSPEC2_RENAMED, YIELD_FIXTURE, …) that call sites pass straight to warnings.warn(). When warnings are errors, warn raises that exact object, and CPython appends to an exception's existing __traceback__ instead of resetting it — so each raise grows the traceback of a process-lifetime global (measured 2 → 4 → 6 → 8 frames over four raises). Failure reports get corrupted: with two tests tripping the same deprecation, the second one's traceback carries 20+ stale frames from the first run and ends pointing at the other test's source line. The frames also pin their locals forever, and concurrent raises mutate shared __traceback__/__context__. The four UnformattedWarning constants are fine, since .format() returns a fresh instance. Fix: build a fresh instance per warn() — fold the 11 into UnformattedWarning (its format() works with no kwargs) or store text and pass warnings.warn(TEXT, Category) — and update the module docstring, which currently mandates the instance form.
src/_pytest/deprecated.pystores 11 deprecations as module-level instances (PRIVATE,CALLSPEC2_RENAMED,YIELD_FIXTURE, …) that call sites pass straight towarnings.warn(). When warnings are errors,warnraises that exact object, and CPython appends to an exception's existing__traceback__instead of resetting it — so each raise grows the traceback of a process-lifetime global (measured 2 → 4 → 6 → 8 frames over four raises). Failure reports get corrupted: with two tests tripping the same deprecation, the second one's traceback carries 20+ stale frames from the first run and ends pointing at the other test's source line. The frames also pin their locals forever, and concurrent raises mutate shared__traceback__/__context__. The fourUnformattedWarningconstants are fine, since.format()returns a fresh instance. Fix: build a fresh instance perwarn()— fold the 11 intoUnformattedWarning(itsformat()works with no kwargs) or store text and passwarnings.warn(TEXT, Category)— and update the module docstring, which currently mandates the instance form.