Reseting entered state in WarningsRecorder (fixes 4617)

This commit is contained in:
Victor Maryama 2019-01-09 12:51:04 +01:00
parent 948a5d5ac6
commit df3b5557d1
1 changed files with 4 additions and 0 deletions

View File

@ -192,6 +192,10 @@ class WarningsRecorder(warnings.catch_warnings):
warnings.warn = self._saved_warn
super(WarningsRecorder, self).__exit__(*exc_info)
# Built-in catch_warnings does not reset entered state so we do it
# manually here for this context manager to become reusable
self._entered = False
class WarningsChecker(WarningsRecorder):
def __init__(self, expected_warning=None, match_expr=None):