tests/run-tests.py: Set __main__ module to __injected_test.
When using unittest (for example) with injected mpy files, not only does the name of the main test module need to be `__main__`, but also the `__main__` module should correspond to this injected module. Otherwise the unittest test won't be detected. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -65,7 +65,9 @@ injected_import_hook_code = """\
|
|||||||
import sys, os, io, vfs
|
import sys, os, io, vfs
|
||||||
class __File(io.IOBase):
|
class __File(io.IOBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
sys.modules['__injected_test'].__name__ = '__main__'
|
module = sys.modules['__injected_test']
|
||||||
|
module.__name__ = '__main__'
|
||||||
|
sys.modules['__main__'] = module
|
||||||
self.off = 0
|
self.off = 0
|
||||||
def ioctl(self, request, arg):
|
def ioctl(self, request, arg):
|
||||||
if request == 4: # MP_STREAM_CLOSE
|
if request == 4: # MP_STREAM_CLOSE
|
||||||
|
|||||||
Reference in New Issue
Block a user