diff options
author | Damien George <damien@micropython.org> | 2024-12-20 22:34:42 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-01-06 17:48:22 +1100 |
commit | 91e30df5f2c9e8c2c84277363a3266d09bc7ae49 (patch) | |
tree | c30d5137b67d178453bc1e0673bfe914f0352ee7 | |
parent | 5d12df51fc431ecb159112bf4a40983c2ccba165 (diff) | |
download | micropython-91e30df5f2c9e8c2c84277363a3266d09bc7ae49.tar.gz micropython-91e30df5f2c9e8c2c84277363a3266d09bc7ae49.zip |
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>
-rwxr-xr-x | tests/run-tests.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py index 3dc0df029e..6af70cb836 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -65,7 +65,9 @@ injected_import_hook_code = """\ import sys, os, io, vfs class __File(io.IOBase): def __init__(self): - sys.modules['__injected_test'].__name__ = '__main__' + module = sys.modules['__injected_test'] + module.__name__ = '__main__' + sys.modules['__main__'] = module self.off = 0 def ioctl(self, request, arg): if request == 4: # MP_STREAM_CLOSE |