diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2004-10-01 16:03:36 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2004-10-01 16:03:36 +0000 |
| commit | 2485ae832ee58c2a1041c45cc91d2adb4b5b72e1 (patch) | |
| tree | 3c007a3ef97658857cc4db97a5dd6b2de1940373 /docutils | |
| parent | 296d659403323266044464dc23bd0a8130589ab5 (diff) | |
| download | docutils-2485ae832ee58c2a1041c45cc91d2adb4b5b72e1.tar.gz | |
added DocutilsTestSupport.testroot
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@2683 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/test/DocutilsTestSupport.py | 3 | ||||
| -rwxr-xr-x | docutils/test/test_dependencies.py | 17 | ||||
| -rwxr-xr-x | docutils/test/test_functional.py | 7 |
3 files changed, 12 insertions, 15 deletions
diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py index 3f8451959..2c30e2b6f 100644 --- a/docutils/test/DocutilsTestSupport.py +++ b/docutils/test/DocutilsTestSupport.py @@ -73,6 +73,9 @@ except: StringList.__repr__ = StringList.__str__ +testroot = os.path.abspath(os.path.dirname(__file__) or os.path.curdir) + + class DevNull: """Output sink.""" diff --git a/docutils/test/test_dependencies.py b/docutils/test/test_dependencies.py index 90ca7d825..61d19a6f2 100755 --- a/docutils/test/test_dependencies.py +++ b/docutils/test/test_dependencies.py @@ -21,14 +21,12 @@ import DocutilsTestSupport class RecordDependenciesTests(unittest.TestCase): def setUp(self): - self.testroot = os.path.dirname(DocutilsTestSupport.__file__) or '.' - self.datadir = os.path.join(self.testroot, 'data') + os.chdir(os.path.join(DocutilsTestSupport.testroot, 'data')) def get_record(self, inputfile=None, **settings): - recordfile = os.path.join(self.datadir, 'record.txt') - settings.setdefault('source_path', os.path.join(self.datadir, - 'dependencies.txt')) + recordfile = 'record.txt' + settings.setdefault('source_path', 'dependencies.txt') settings.setdefault('settings_overrides', {}) settings['settings_overrides'] = settings['settings_overrides'].copy() settings['settings_overrides']['_disable_config'] = 1 @@ -38,8 +36,7 @@ class RecordDependenciesTests(unittest.TestCase): docutils.core.publish_file(destination=DocutilsTestSupport.DevNull(), **settings) settings['settings_overrides']['record_dependencies'].close() - return [dep.split('/')[-1] - for dep in open(recordfile).read().splitlines()] + return open(recordfile).read().splitlines() def test_dependencies(self): self.assertEqual(self.get_record(), @@ -53,8 +50,8 @@ class RecordDependenciesTests(unittest.TestCase): def test_csv_dependencies(self): try: import csv - self.assertEqual(self.get_record(source_path=os.path.join( - self.datadir, 'csv_dep.txt')), ['csv_data.txt']) + self.assertEqual(self.get_record(source_path='csv_dep.txt'), + ['csv_data.txt']) except ImportError: pass @@ -63,7 +60,7 @@ class RecordDependenciesTests(unittest.TestCase): # Parameters to publish_file. s = {'settings_overrides': {}} so = s['settings_overrides'] - so['stylesheet_path'] = os.path.join(self.datadir, 'stylesheet.txt') + so['stylesheet_path'] = 'stylesheet.txt' so['stylesheet'] = None s['writer_name'] = 'html' self.assert_('stylesheet.txt' not in diff --git a/docutils/test/test_functional.py b/docutils/test/test_functional.py index 091532dc4..aa55b0651 100755 --- a/docutils/test/test_functional.py +++ b/docutils/test/test_functional.py @@ -22,9 +22,6 @@ import docutils.core import DocutilsTestSupport -# Ugly magic to determine the test directory. -testroot = os.path.dirname(DocutilsTestSupport.__file__) or '.' - datadir = 'functional' """The directory to store the data needed for the functional tests.""" @@ -40,7 +37,7 @@ class FunctionalTestSuite(DocutilsTestSupport.CustomTestSuite): def __init__(self): """Process all config files in functional/tests/.""" DocutilsTestSupport.CustomTestSuite.__init__(self) - os.chdir(testroot) + os.chdir(DocutilsTestSupport.testroot) self.added = 0 os.path.walk(join_path(datadir, 'tests'), self.walker, None) assert self.added, 'No functional tests found.' @@ -76,7 +73,7 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase): def test(self): """Process self.configfile.""" - os.chdir(testroot) + os.chdir(DocutilsTestSupport.testroot) # Keyword parameters for publish_file: params = {} # Initialize 'settings_overrides' for test settings scripts, |
