bpo-2604: Make doctest.DocTestCase reset globs in teardown (GH-31932)

Co-authored-by: Piet Delport
Co-authored-by: Hugo Lopes Tavares
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 7ba7eae508)

Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-03-22 14:27:26 -07:00 committed by GitHub
parent af341ebf00
commit 3c6019035f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -2159,6 +2159,7 @@ class DocTestCase(unittest.TestCase):
unittest.TestCase.__init__(self)
self._dt_optionflags = optionflags
self._dt_checker = checker
self._dt_globs = test.globs.copy()
self._dt_test = test
self._dt_setUp = setUp
self._dt_tearDown = tearDown
@ -2175,7 +2176,9 @@ class DocTestCase(unittest.TestCase):
if self._dt_tearDown is not None:
self._dt_tearDown(test)
# restore the original globs
test.globs.clear()
test.globs.update(self._dt_globs)
def runTest(self):
test = self._dt_test