diff options
| -rw-r--r-- | BUGS.txt | 7 | ||||
| -rw-r--r-- | docutils/readers/python/__init__.py | 3 | ||||
| -rw-r--r-- | docutils/readers/python/moduleparser.py | 2 | ||||
| -rw-r--r-- | test/package_unittest.py | 38 |
4 files changed, 32 insertions, 18 deletions
@@ -177,6 +177,13 @@ Also see the `SourceForge Bug Tracker`_. all IDs from definitions after the first substitution reference is processed. +* Under Python 2.1, the test suite should skip tests of + ``docutils/readers/python/`` but still tries to import it from + ``test/test_readers/test_python/test_functions.py``. This now + causes an extra error message about failed import; instead, it + should not have been skipped completely (a message about the + skipping is printed anyway). + .. Local Variables: diff --git a/docutils/readers/python/__init__.py b/docutils/readers/python/__init__.py index 14d01c0c8..6c027641d 100644 --- a/docutils/readers/python/__init__.py +++ b/docutils/readers/python/__init__.py @@ -6,6 +6,9 @@ """ This package contains the Python Source Reader modules. + +It requires Python 2.2 or higher (`moduleparser` depends on `compiler` and +`tokenizer` modules). """ __docformat__ = 'reStructuredText' diff --git a/docutils/readers/python/moduleparser.py b/docutils/readers/python/moduleparser.py index ddfe21ea7..8fd7ed67b 100644 --- a/docutils/readers/python/moduleparser.py +++ b/docutils/readers/python/moduleparser.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. """ -Parser for Python modules. +Parser for Python modules. Requires Python 2.2 or higher. The `parse_module()` function takes a module's text and file name, runs it through the module parser (using compiler.py and tokenize.py) diff --git a/test/package_unittest.py b/test/package_unittest.py index 019d6fb38..135b54f47 100644 --- a/test/package_unittest.py +++ b/test/package_unittest.py @@ -99,25 +99,29 @@ def loadTestModules(path, name='', packages=None): for mod in testModules: if debug: print >>sys.stderr, "importing %s" % mod - module = import_module(mod) - # if there's a suite defined, incorporate its contents try: - suite = getattr(module, 'suite') - except AttributeError: - # Look for individual tests - moduleTests = testLoader.loadTestsFromModule(module) - # unittest.TestSuite.addTests() doesn't work as advertised, - # as it can't load tests from another TestSuite, so we have - # to cheat: - testSuite.addTest(moduleTests) - continue - if type(suite) == types.FunctionType: - testSuite.addTest(suite()) - elif type(suite) == types.InstanceType \ - and isinstance(suite, unittest.TestSuite): - testSuite.addTest(suite) + module = import_module(mod) + except ImportError: + print >>sys.stderr, "ERROR: Can't import %s, skipping its tests!" % mod else: - raise AssertionError, "don't understand suite (%s)" % mod + # if there's a suite defined, incorporate its contents + try: + suite = getattr(module, 'suite') + except AttributeError: + # Look for individual tests + moduleTests = testLoader.loadTestsFromModule(module) + # unittest.TestSuite.addTests() doesn't work as advertised, + # as it can't load tests from another TestSuite, so we have + # to cheat: + testSuite.addTest(moduleTests) + continue + if type(suite) == types.FunctionType: + testSuite.addTest(suite()) + elif type(suite) == types.InstanceType \ + and isinstance(suite, unittest.TestSuite): + testSuite.addTest(suite) + else: + raise AssertionError, "don't understand suite (%s)" % mod sys.path.pop(0) return testSuite |
