File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818from testflo .cover import start_coverage , stop_coverage
1919
2020from testflo .util import get_module , ismethod , get_memory_usage , \
21- get_testpath , _options2args
21+ get_testpath , _options2args , _testing_path
2222from testflo .utresult import UnitTestResult
2323from testflo .devnull import DevNull
2424
@@ -46,12 +46,6 @@ def __init__(self):
4646 self .size = 1
4747
4848
49- # create a copy of sys.path with an extra entry at the beginning so that
50- # we can quickly replace the first entry with the curent test's dir rather
51- # than constantly copying the whole sys.path
52- _testing_path = ['.' ] + sys .path
53-
54-
5549@contextmanager
5650def testcontext (test ):
5751 global _testing_path
Original file line number Diff line number Diff line change 1919
2020from testflo .cover import start_coverage , stop_coverage
2121
22+ # create a copy of sys.path with an extra entry at the beginning so that
23+ # we can quickly replace the first entry with the curent test's dir rather
24+ # than constantly copying the whole sys.path
25+ _testing_path = ['.' ] + sys .path
26+
27+
2228_store = {}
2329
2430
@@ -337,7 +343,11 @@ def find_module(name):
337343
338344
339345def try_import (fname , modpath ):
346+ global _testing_path
340347 try :
348+ _testing_path [0 ] = os .path .dirname (fname )
349+ old_sys_path = sys .path
350+ sys .path = _testing_path
341351 mod = import_module (modpath )
342352 except ImportError :
343353 # this might be a module that's not in the same
@@ -356,6 +366,8 @@ def try_import(fname, modpath):
356366 del sys .modules [modpath ]
357367 finally :
358368 sys .path = oldpath
369+ finally :
370+ sys .path = old_sys_path
359371
360372 return mod
361373
You can’t perform that action at this time.
0 commit comments