Skip to content

Commit 7adcf89

Browse files
committed
regress test for cwd not restored
1 parent 0b50ae9 commit 7adcf89

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/test_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,17 @@ def test_exit(self):
806806
with self.assertRaises(RuntimeError):
807807
do_command(args, HERE)
808808

809+
def test_restore_cwd(self):
810+
"Ensure do_command in a different cwd restores cwd after error."
811+
before = os.getcwd()
812+
# after = None
813+
try:
814+
do_command(cmd=['ls /does-not-exist'], cwd=os.path.dirname(before))
815+
except RuntimeError as exc:
816+
pass
817+
finally:
818+
after = os.getcwd()
819+
self.assertEqual(before, after)
809820

810821
class FlattenTest(unittest.TestCase):
811822
def test_good(self):

0 commit comments

Comments
 (0)