[stem/master] Using absolute paths for doctest

commit 3abe1400567b3479a567b96f9da41cf9152b6fa4 Author: Damian Johnson <atagar@torproject.org> Date: Sun Oct 27 09:20:06 2013 -0700 Using absolute paths for doctest By default doctests refuse absolute paths, which required us to do a gross hack. It turns out that the module has a module_relative argument that lets us accept them, so dropping the hack. Also making sure we run all doctests before failing (so we get output for all of them before aborting). --- test/unit/doctest.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/unit/doctest.py b/test/unit/doctest.py index cae58a7..a7a2a20 100644 --- a/test/unit/doctest.py +++ b/test/unit/doctest.py @@ -21,10 +21,11 @@ except ImportError: class TestDocumentation(unittest.TestCase): def test_examples(self): - cwd = os.getcwd() + stem_dir = os.path.join(test.util.STEM_BASE, 'stem') + is_failed = False - for path in test.util._get_files_with_suffix(os.path.join(test.util.STEM_BASE, 'stem')): - path = '../../' + path[len(cwd) + 1:] + for path in test.util._get_files_with_suffix(stem_dir): + args = {'module_relative': False} test_run = None if path.endswith('/stem/util/conf.py'): @@ -35,9 +36,12 @@ class TestDocumentation(unittest.TestCase): pass # examples refrence a control instance elif path.endswith('/stem/version.py'): with patch('stem.version.get_system_tor_version', Mock(return_value = stem.version.Version('0.2.1.30'))): - test_run = doctest.testfile(path) + test_run = doctest.testfile(path, **args) else: - test_run = doctest.testfile(path) + test_run = doctest.testfile(path, **args) if test_run and test_run.failed > 0: - self.fail() + is_failed = True + + if is_failed: + self.fail("doctests encountered errors")
participants (1)
-
atagar@torproject.org