diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-03-09 12:39:50 +0100 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-03-09 12:39:50 +0100 |
commit | c685367cbd6abf1c6ae442df759e39b25a907d3b (patch) | |
tree | 37a942f44512c7b567447de41b1ff2c8496898be /test-cli/test/helpers/changedir.py | |
parent | a03055f657d2e970e45e7ea2a3e66857f821eabd (diff) | |
download | board-c685367cbd6abf1c6ae442df759e39b25a907d3b.zip board-c685367cbd6abf1c6ae442df759e39b25a907d3b.tar.gz board-c685367cbd6abf1c6ae442df759e39b25a907d3b.tar.bz2 |
Fixed several test procedures.
Diffstat (limited to 'test-cli/test/helpers/changedir.py')
-rw-r--r-- | test-cli/test/helpers/changedir.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test-cli/test/helpers/changedir.py b/test-cli/test/helpers/changedir.py new file mode 100644 index 0000000..fad9ade --- /dev/null +++ b/test-cli/test/helpers/changedir.py @@ -0,0 +1,14 @@ +import os + + +class changedir: + """Context manager for changing the current working directory""" + def __init__(self, newPath): + self.newPath = os.path.expanduser(newPath) + + def __enter__(self): + self.savedPath = os.getcwd() + os.chdir(self.newPath) + + def __exit__(self, etype, value, traceback): + os.chdir(self.savedPath)
\ No newline at end of file |