mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 11:40:18 +01:00
tests/import: Make import_override and pkg7 tests behave under CPython.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
|
||||
def custom_import(name, globals, locals, fromlist, level):
|
||||
# CPython always tries to import _io, so just let that through as-is.
|
||||
if name == "_io":
|
||||
return orig_import(name, globals, locals, fromlist, level)
|
||||
|
||||
print("import", name, fromlist, level)
|
||||
|
||||
class M:
|
||||
|
||||
@@ -5,7 +5,9 @@ print(mod1.foo)
|
||||
print(bar)
|
||||
|
||||
# attempted relative import beyond top-level package
|
||||
# On older versions of CPython (eg 3.8) this is a ValueError, but on
|
||||
# newer CPython (eg 3.11) and MicroPython it's an ImportError.
|
||||
try:
|
||||
from .... import mod1
|
||||
except ImportError:
|
||||
except (ImportError, ValueError):
|
||||
print("ImportError")
|
||||
|
||||
Reference in New Issue
Block a user