From a0d0e184a40c06298879d1dec4ba2271afca31d5 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 9 Jan 2006 03:06:58 +0000 Subject: moved clear_roles to DocutilsTestSupport.CustomTestCase so that it is used globally git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@4254 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/test/DocutilsTestSupport.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'docutils/test/DocutilsTestSupport.py') diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py index c3c0aa2a2..1fbecbb32 100644 --- a/docutils/test/DocutilsTestSupport.py +++ b/docutils/test/DocutilsTestSupport.py @@ -172,6 +172,21 @@ class CustomTestCase(StandardTestCase): def __repr__(self): return "<%s %s>" % (self.id, unittest.TestCase.__repr__(self)) + def clear_roles(self): + # Language-specific roles and roles added by the + # "default-role" and "role" directives are currently stored + # globally in the roles._roles dictionary. This workaround + # empties that dictionary. + roles._roles = {} + + def setUp(self): + StandardTestCase.setUp(self) + self.clear_roles() + + def tearDown(self): + StandardTestCase.tearDown(self) + self.clear_roles() + def compare_output(self, input, output, expected): """`input`, `output`, and `expected` should all be strings.""" if isinstance(input, UnicodeType): @@ -421,8 +436,6 @@ class ParserTestCase(CustomTestCase): settings = self.settings.copy() settings.__dict__.update(self.suite_settings) document = utils.new_document('test data', settings) - # Remove any additions made by "role" directives: - roles._roles = {} self.parser.parse(self.input, document) output = document.pformat() self.compare_output(self.input, output, self.expected) -- cgit v1.2.1