Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcdb3f82

Browse files
committed
tests/run-tests.py: Set name of injected test module to '__main__'.
Running unittest-based tests with --via-mpy is currently broken, becausethe unittest test needs the module to be named `__main__`, whereas it'sactually called `__injected_test`.Fix this by changing the name when the file is opened.Signed-off-by: Damien George <damien@micropython.org>
1 parentd10cda6 commitcdb3f82

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎tests/run-tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ def base_path(*p):
5959
os.environ["PYTHONIOENCODING"]="utf-8"
6060

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp