test_walks.py 999 B

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