Add test for utils.chdir
MODIFY
tests/test_utils.py
tests/test_utils.py
"""
Tests for repo2docker/utils.py
"""
+import os
+from tempfile import TemporaryDirectory
from repo2docker import utils
import pytest
import subprocess
@@ -35,3 +37,11 @@ def test_capture_cmd_capture_fail():
'/bin/bash', '-c', 'echo test; exit 1 '
], capture=True):
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

Add test for utils.chdir