diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-03-22 21:01:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 21:01:15 (GMT) |
commit | 7ba7eae50803b11766421cb8aae1780058a57e2b (patch) | |
tree | ecce761c8142f3cc886aa9418b71dff18a53da3e /Lib/doctest.py | |
parent | 4aea656d62860e78cd8384f2de375f0d4f1db579 (diff) | |
download | cpython-7ba7eae50803b11766421cb8aae1780058a57e2b.zip cpython-7ba7eae50803b11766421cb8aae1780058a57e2b.tar.gz cpython-7ba7eae50803b11766421cb8aae1780058a57e2b.tar.bz2 |
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>
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 4735b59..ed94d15 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -2171,6 +2171,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 @@ -2187,7 +2188,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 |