move: awareness of cwd when moving files

fix #1636
This commit is contained in:
Mr. Outis
2019-02-19 11:55:43 -06:00
parent f0b1c30222
commit 758c71e249
4 changed files with 34 additions and 4 deletions
+12
View File
@@ -1,5 +1,7 @@
import yaml
import os
from mock import MagicMock
from contextlib import contextmanager
def spy(method_to_decorate):
@@ -16,3 +18,13 @@ def spy(method_to_decorate):
def load_stage_file(path):
with open(path, "r") as fobj:
return yaml.safe_load(fobj)
@contextmanager
def cd(newdir):
prevdir = os.getcwd()
os.chdir(os.path.expanduser(newdir))
try:
yield
finally:
os.chdir(prevdir)