diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-12-06 11:29:54 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-12-06 11:29:54 +0100 |
commit | 8e8fd468182916b0e10b30d1c5a3cbf4a7714a16 (patch) | |
tree | 5f7ad1d0b32d53c5d7762bb31ba75b9901d0a399 /testlib.py | |
parent | e74ebf98430fbf8020b92951b87875d5edf59c0c (diff) | |
download | logilab-common-8e8fd468182916b0e10b30d1c5a3cbf4a7714a16.tar.gz |
cleanup: remove 2.3 support in testlib
Diffstat (limited to 'testlib.py')
-rw-r--r-- | testlib.py | 55 |
1 files changed, 18 insertions, 37 deletions
@@ -1133,43 +1133,24 @@ class SkippedSuite(unittest.TestSuite): self.skipped_test('doctest module has no DocTestSuite class') -# DocTestFinder was introduced in python2.4 -if sys.version_info >= (2, 4): - class DocTestFinder(doctest.DocTestFinder): - - def __init__(self, *args, **kwargs): - self.skipped = kwargs.pop('skipped', ()) - doctest.DocTestFinder.__init__(self, *args, **kwargs) - - def _get_test(self, obj, name, module, globs, source_lines): - """override default _get_test method to be able to skip tests - according to skipped attribute's value - - Note: Python (<=2.4) use a _name_filter which could be used for that - purpose but it's no longer available in 2.5 - Python 2.5 seems to have a [SKIP] flag - """ - if getattr(obj, '__name__', '') in self.skipped: - return None - return doctest.DocTestFinder._get_test(self, obj, name, module, - globs, source_lines) -else: - # this is a hack to make skipped work with python <= 2.3 - class DocTestFinder(object): - def __init__(self, skipped): - self.skipped = skipped - self.original_find_tests = doctest._find_tests - doctest._find_tests = self._find_tests - - def _find_tests(self, module, prefix=None): - tests = [] - for testinfo in self.original_find_tests(module, prefix): - testname, _, _, _ = testinfo - # testname looks like A.B.C.function_name - testname = testname.split('.')[-1] - if testname not in self.skipped: - tests.append(testinfo) - return tests +class DocTestFinder(doctest.DocTestFinder): + + def __init__(self, *args, **kwargs): + self.skipped = kwargs.pop('skipped', ()) + doctest.DocTestFinder.__init__(self, *args, **kwargs) + + def _get_test(self, obj, name, module, globs, source_lines): + """override default _get_test method to be able to skip tests + according to skipped attribute's value + + Note: Python (<=2.4) use a _name_filter which could be used for that + purpose but it's no longer available in 2.5 + Python 2.5 seems to have a [SKIP] flag + """ + if getattr(obj, '__name__', '') in self.skipped: + return None + return doctest.DocTestFinder._get_test(self, obj, name, module, + globs, source_lines) class DocTest(TestCase): |