mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
gh-117347: Fix test_clinic side effects (#117363)
Save/restore converters in ClinicWholeFileTest and
ClinicExternalTest.
(cherry picked from commit 35b6c4a4da
)
This commit is contained in:
parent
2a18945dc6
commit
c80d13838d
1 changed files with 18 additions and 0 deletions
|
@ -21,6 +21,20 @@ with test_tools.imports_under_tool('clinic'):
|
|||
from clinic import DSLParser
|
||||
|
||||
|
||||
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 _ParserBase(TestCase):
|
||||
maxDiff = None
|
||||
|
||||
|
@ -107,6 +121,7 @@ class FakeClinic:
|
|||
|
||||
class ClinicWholeFileTest(_ParserBase):
|
||||
def setUp(self):
|
||||
save_restore_converters(self)
|
||||
self.clinic = clinic.Clinic(clinic.CLanguage(None), filename="test.c")
|
||||
|
||||
def expect_failure(self, raw):
|
||||
|
@ -1369,6 +1384,9 @@ class ClinicExternalTest(TestCase):
|
|||
maxDiff = None
|
||||
clinic_py = os.path.join(test_tools.toolsdir, "clinic", "clinic.py")
|
||||
|
||||
def setUp(self):
|
||||
save_restore_converters(self)
|
||||
|
||||
def _do_test(self, *args, expect_success=True):
|
||||
with subprocess.Popen(
|
||||
[sys.executable, "-Xutf8", self.clinic_py, *args],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue