diff --git a/tests/test_utils.py b/tests/test_utils.py index 17c78aa0..e5eafec2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,8 @@ """ Tests for repo2docker/utils.py """ +import os +from tempfile import TemporaryDirectory from repo2docker import utils import pytest import subprocess @@ -34,4 +36,12 @@ def test_capture_cmd_capture_fail(): for line in utils.execute_cmd([ '/bin/bash', '-c', 'echo test; exit 1 ' ], capture=True): - assert line == 'test\n' \ No newline at end of file + assert line == 'test\n' + + +def test_chdir(): + with TemporaryDirectory() as d: + cur_cwd = os.getcwd() + with utils.chdir(d): + assert os.getcwd() == d + assert os.getcwd() == cur_cwd