File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from testflo .cover import start_coverage , stop_coverage
2020
2121from testflo .util import get_module , ismethod , get_memory_usage , \
22- get_testpath , _options2args
22+ get_testpath , _options2args , _testing_path
2323from testflo .utresult import UnitTestResult
2424from testflo .devnull import DevNull
2525
@@ -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 1818from argparse import ArgumentParser , _AppendAction
1919
2020
21+ # create a copy of sys.path with an extra entry at the beginning so that
22+ # we can quickly replace the first entry with the curent test's dir rather
23+ # than constantly copying the whole sys.path
24+ _testing_path = ['.' ] + sys .path
25+
26+
2127_store = {}
2228
2329
@@ -336,7 +342,11 @@ def find_module(name):
336342
337343
338344def try_import (fname , modpath ):
345+ global _testing_path
339346 try :
347+ _testing_path [0 ] = os .path .dirname (fname )
348+ old_sys_path = sys .path
349+ sys .path = _testing_path
340350 mod = import_module (modpath )
341351 except ImportError :
342352 # this might be a module that's not in the same
@@ -355,6 +365,8 @@ def try_import(fname, modpath):
355365 del sys .modules [modpath ]
356366 finally :
357367 sys .path = oldpath
368+ finally :
369+ sys .path = old_sys_path
358370
359371 return mod
360372
You can’t perform that action at this time.
0 commit comments