From ff8dbd0ad8d50cf1ff9c07e0c6e04fe26d58cc9a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 22 Jun 2017 08:54:39 -0300 Subject: [PATCH] Add tracebackhide to function call form of deprecated_call --- _pytest/recwarn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_pytest/recwarn.py b/_pytest/recwarn.py index 36b22e940..9cc404a49 100644 --- a/_pytest/recwarn.py +++ b/_pytest/recwarn.py @@ -45,6 +45,7 @@ def deprecated_call(func=None, *args, **kwargs): if not func: return _DeprecatedCallContext() else: + __tracebackhide__ = True with _DeprecatedCallContext(): return func(*args, **kwargs) @@ -71,7 +72,7 @@ class _DeprecatedCallContext(object): def __exit__(self, exc_type, exc_val, exc_tb): warnings.warn_explicit = self._old_warn_explicit warnings.warn = self._old_warn - + if exc_type is None: deprecation_categories = (DeprecationWarning, PendingDeprecationWarning) if not any(issubclass(c, deprecation_categories) for c in self._captured_categories):