summaryrefslogtreecommitdiff
path: root/test-cli/test/helpers/changedir.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iatec.biz>2021-11-06 16:28:38 +0100
committerManel Caro <mcaro@iatec.biz>2021-11-06 16:28:38 +0100
commitcf19bfe18cbd283b188a858ee1629f9909c924f4 (patch)
tree1efb23519727130058401df090ab1b5f4cc8ba99 /test-cli/test/helpers/changedir.py
parentb6932fbaf898724ae87c29f8965621610f377084 (diff)
parentd5b273a3b58a250742049df4ca0ef0ba54f53d33 (diff)
downloadboard-rel.0.1.zip
board-rel.0.1.tar.gz
board-rel.0.1.tar.bz2
Merge branch 'sopa-test'rel.0.1sopa-test
Diffstat (limited to 'test-cli/test/helpers/changedir.py')
-rw-r--r--test-cli/test/helpers/changedir.py14
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