01_reset_chdir 802 B

123456789101112131415161718192021
  1. Description: Reset current working directory after running doctests
  2. Author: Jelmer Vernooij <jelmer@debian.org>
  3. Status: Cherry-picked from upstream, will be in 0.8.2
  4. === modified file 'dulwich/tests/__init__.py'
  5. --- old/dulwich/tests/__init__.py 2011-08-21 21:37:18 +0000
  6. +++ new/dulwich/tests/__init__.py 2011-11-01 11:30:18 +0000
  7. @@ -104,10 +104,12 @@
  8. ]
  9. tutorial_files = ["../../docs/tutorial/%s.txt" % name for name in tutorial]
  10. def setup(test):
  11. + test.__old_cwd = os.getcwd()
  12. test.__dulwich_tempdir = tempfile.mkdtemp()
  13. os.chdir(test.__dulwich_tempdir)
  14. def teardown(test):
  15. shutil.rmtree(test.__dulwich_tempdir)
  16. + os.chdir(test.__old_cwd)
  17. return doctest.DocFileSuite(setUp=setup, tearDown=teardown,
  18. *tutorial_files)