Skip to content

tests/run-tests.py: Set name of injected test module to '__main__'. #16433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ def base_path(*p):
os.environ["PYTHONIOENCODING"] = "utf-8"

# Code to allow a target MicroPython to import an .mpy from RAM
# Note: the module is named `__injected_test` but it needs to have `__name__` set to
# `__main__` so that the test sees itself as the main module, eg so unittest works.
injected_import_hook_code = """\
import sys, os, io, vfs
class __File(io.IOBase):
def __init__(self):
sys.modules['__injected_test'].__name__ = '__main__'
self.off = 0
def ioctl(self, request, arg):
return 0
Expand Down
Loading