summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_clinic.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 52cb4d6..f95bf85 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -52,6 +52,20 @@ def _expect_failure(tc, parser, code, errmsg, *, filename=None, lineno=None,
return cm.exception
+def restore_dict(converters, old_converters):
+ converters.clear()
+ converters.update(old_converters)
+
+
+def save_restore_converters(testcase):
+ testcase.addCleanup(restore_dict, clinic.converters,
+ clinic.converters.copy())
+ testcase.addCleanup(restore_dict, clinic.legacy_converters,
+ clinic.legacy_converters.copy())
+ testcase.addCleanup(restore_dict, clinic.return_converters,
+ clinic.return_converters.copy())
+
+
class ClinicWholeFileTest(TestCase):
maxDiff = None
@@ -60,6 +74,7 @@ class ClinicWholeFileTest(TestCase):
filename=filename, lineno=lineno)
def setUp(self):
+ save_restore_converters(self)
self.clinic = _make_clinic(filename="test.c")
def test_eol(self):
@@ -2431,6 +2446,9 @@ class ClinicParserTest(TestCase):
class ClinicExternalTest(TestCase):
maxDiff = None
+ def setUp(self):
+ save_restore_converters(self)
+
def run_clinic(self, *args):
with (
support.captured_stdout() as out,