Debian Codegraph @

adventure/tests/test_walks.py

raw
1 """Test suite.
2
3 Copyright 2010-2015 Brandon Rhodes. Licensed as free software under the
4 Apache License, Version 2.0 as detailed in the accompanying README.txt.
5
6 """
7 import doctest
8 import os
9 import shutil
10 import tempfile
11
12 def load_tests(loader, tests, pattern):
13 cd = ChdirTemp()
14 tests.addTests(doctest.DocFileSuite(
15 '../README.txt', optionflags=doctest.NORMALIZE_WHITESPACE,
16 setUp=cd.setup, tearDown=cd.teardown))
17 tests.addTests(doctest.DocFileSuite('syntax.txt'))
18 tests.addTests(doctest.DocFileSuite('vignettes.txt'))
19 tests.addTests(doctest.DocFileSuite('walkthrough1.txt'))
20 tests.addTests(doctest.DocFileSuite('walkthrough2.txt'))
21 tests.addTests(doctest.DocFileSuite('walkthrough3.txt'))
22 return tests
23
24 class ChdirTemp(object):
25 def setup(self, doctest_object):
26 self.old_directory = os.getcwd()
27 self.tmp_directory = tempfile.mkdtemp()
28 os.chdir(self.tmp_directory)
29
30 def teardown(self, doctest_object):
31 os.chdir(self.old_directory)
32 shutil.rmtree(self.tmp_directory)