summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-09-14 19:26:34 +1000
committerDamien George <damien@micropython.org>2025-10-01 23:59:15 +1000
commit7373cbba6b6f32476fc68a40a11fcba1cf1c7d3c (patch)
treec6bfcfbead2d14ebc4fcbde55173ec17e66a0478 /tests
parent957e6b05e69524d1b03f3ccb446b433085a4de8e (diff)
tests/import: Skip import tests where needed.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/import/builtin_ext.py6
-rw-r--r--tests/import/import_broken.py6
-rw-r--r--tests/import/import_file.py4
-rw-r--r--tests/import/import_pkg9.py2
-rw-r--r--tests/import/import_star_error.py5
5 files changed, 22 insertions, 1 deletions
diff --git a/tests/import/builtin_ext.py b/tests/import/builtin_ext.py
index 87465f1d5..aecbbb263 100644
--- a/tests/import/builtin_ext.py
+++ b/tests/import/builtin_ext.py
@@ -1,3 +1,9 @@
+try:
+ import uos, utime
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
# Verify that sys is a builtin.
import sys
diff --git a/tests/import/import_broken.py b/tests/import/import_broken.py
index 3c7cf4a49..440922157 100644
--- a/tests/import/import_broken.py
+++ b/tests/import/import_broken.py
@@ -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.
diff --git a/tests/import/import_file.py b/tests/import/import_file.py
index 90ec4e41e..4cf307641 100644
--- a/tests/import/import_file.py
+++ b/tests/import/import_file.py
@@ -1,3 +1,7 @@
+if "__file__" not in globals():
+ print("SKIP")
+ raise SystemExit
+
import import1b
print(import1b.__file__)
diff --git a/tests/import/import_pkg9.py b/tests/import/import_pkg9.py
index 4de028494..c2e0b618b 100644
--- a/tests/import/import_pkg9.py
+++ b/tests/import/import_pkg9.py
@@ -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))
diff --git a/tests/import/import_star_error.py b/tests/import/import_star_error.py
index 9e1757b6e..73d9c863d 100644
--- a/tests/import/import_star_error.py
+++ b/tests/import/import_star_error.py
@@ -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 *")