Ensure we go back to default path implementation

If an error is raised within the mock path context and catched upstream the
rest of the tests will run with the mocked path and fail horribly.
This commit is contained in:
Thomas Scholtes 2014-02-23 16:38:41 +01:00
parent 1253cb695d
commit c73ada92c8

View file

@ -257,14 +257,18 @@ class Bag(object):
def platform_windows():
import ntpath
old_path = os.path
os.path = ntpath
yield
os.path = old_path
try:
os.path = ntpath
yield
finally:
os.path = old_path
@contextmanager
def platform_posix():
import posixpath
old_path = os.path
os.path = posixpath
yield
os.path = old_path
try:
os.path = posixpath
yield
finally:
os.path = old_path