Add test for utils.chdir

pull/494/head
yuvipanda 2018-12-10 23:13:56 -08:00
rodzic ee9b150ef8
commit b441176a6a
1 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -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'
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