From c41791b2a3356697979ce6d3de142c3662613903 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Apr 22 2018 17:44:15 +0000 Subject: Change back to original dir in tests Some of the tests need to run in a clone of a git repo. However we need to make sure we change back to the original working directory. Otherwise generating test coverage fails as it tries to write it into current working dir, which no longer exists. --- diff --git a/tests/test_utils.py b/tests/test_utils.py index bc18b9e..2f4a445 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -25,6 +25,7 @@ class GitTestCase(unittest.TestCase): print(cp.stdout) def setUp(self): + self.orig_path = os.getcwd() # Create git repository with some basic content self.repo = tempfile.mkdtemp(prefix='test_current_branch_') self.cmd(['git', 'init']) @@ -37,6 +38,8 @@ class GitTestCase(unittest.TestCase): def tearDown(self): shutil.rmtree(self.repo) + # Change back to original working directory + os.chdir(self.orig_path) class TestGetDefaultBranch(GitTestCase):