diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-06-19 14:51:42 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-06-19 14:51:42 +0000 |
| commit | d90d048247c7f3012414659a52078b6c8a89765f (patch) | |
| tree | 5fe136e4b1148b6b683609ce484572475d03da2a /test/DocutilsTestSupport.py | |
| parent | 4220823618786ebcf147ce3dee195b6acdd4bb00 (diff) | |
| download | docutils-d90d048247c7f3012414659a52078b6c8a89765f.tar.gz | |
added deactivation of config file reading (for easier testing)
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3511 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'test/DocutilsTestSupport.py')
| -rw-r--r-- | test/DocutilsTestSupport.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py index d9f78f774..5aadf91bb 100644 --- a/test/DocutilsTestSupport.py +++ b/test/DocutilsTestSupport.py @@ -17,6 +17,7 @@ Exports the following: - `tableparser` is 'docutils.parsers.rst.tableparser' :Classes: + - `StandardTestCase` - `CustomTestCase` - `CustomTestSuite` - `TransformTestCase` @@ -88,16 +89,29 @@ class DevNull: pass -class CustomTestCase(unittest.TestCase): +class StandardTestCase(unittest.TestCase): + + """ + Helper class, providing the same interface as unittest.TestCase, + but with useful setUp and tearDown methods. + """ + + def setUp(self): + os.chdir(testroot) + frontend._globally_deactivate_config_files = 1 + + def tearDown(self): + frontend._globally_deactivate_config_files = 0 + + +class CustomTestCase(StandardTestCase): """ Helper class, providing extended functionality over unittest.TestCase. - This isn't specific to Docutils but of general use when dealing - with large amounts of text. The methods failUnlessEqual and - failIfEqual have been overwritten to provide better support for - multi-line strings. Furthermore, see the compare_output method - and the parameter list of __init__. + The methods failUnlessEqual and failIfEqual have been overwritten + to provide better support for multi-line strings. Furthermore, + see the compare_output method and the parameter list of __init__. """ compare = docutils_difflib.Differ().compare @@ -135,11 +149,11 @@ class CustomTestCase(unittest.TestCase): def compare_output(self, input, output, expected): """`input`, `output`, and `expected` should all be strings.""" - if type(input) == UnicodeType: + if isinstance(input, UnicodeType): input = input.encode('raw_unicode_escape') - if type(output) == UnicodeType: + if isinstance(output, UnicodeType): output = output.encode('raw_unicode_escape') - if type(expected) == UnicodeType: + if isinstance(expected, UnicodeType): expected = expected.encode('raw_unicode_escape') try: self.assertEquals(output, expected) @@ -167,9 +181,6 @@ class CustomTestCase(unittest.TestCase): raise self.failureException, \ (msg or '%s == %s' % _format_str(first, second)) - def setUp(self): - os.chdir(testroot) - # Synonyms for assertion methods assertEqual = assertEquals = failUnlessEqual |
