tests/import: Skip import tests where needed.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-09-14 19:26:34 +10:00
parent 957e6b05e6
commit 7373cbba6b
5 changed files with 22 additions and 1 deletions

View File

@@ -1,3 +1,9 @@
try:
import uos, utime
except ImportError:
print("SKIP")
raise SystemExit
# Verify that sys is a builtin.
import sys

View File

@@ -1,3 +1,9 @@
try:
Exception.__class__
except AttributeError:
print("SKIP")
raise SystemExit
import sys, pkg
# Modules we import are usually added to sys.modules.

View File

@@ -1,3 +1,7 @@
if "__file__" not in globals():
print("SKIP")
raise SystemExit
import import1b
print(import1b.__file__)

View File

@@ -13,4 +13,4 @@ pkg9.mod2()
import pkg9.mod2
pkg9.mod1()
print(pkg9.mod2.__name__, type(pkg9.mod2).__name__)
print(pkg9.mod2.__name__, type(pkg9.mod2))

View File

@@ -1,5 +1,10 @@
# test errors with import *
if not hasattr(object, "__init__"):
# target doesn't have MICROPY_CPYTHON_COMPAT enabled, so doesn't check for "import *"
print("SKIP")
raise SystemExit
# 'import *' is not allowed in function scope
try:
exec("def foo(): from x import *")