diff --git a/_pytest/recwarn.py b/_pytest/recwarn.py index 4fd41fa8a..9031bdbda 100644 --- a/_pytest/recwarn.py +++ b/_pytest/recwarn.py @@ -216,8 +216,8 @@ class WarningsChecker(WarningsRecorder): # only check if we're not currently handling an exception if all(a is None for a in exc_info): if self.expected_warning is not None: - if not any(issubclass(r.category, exp_warning) for - exp_warning in self.expected_warning for r in self): + if not any(issubclass(r.category, self.expected_warning) + for r in self): __tracebackhide__ = True pytest.fail("DID NOT WARN. No warnings of type {0} was emitted. " "The list of emitted warnings is: {1}.".format(