summaryrefslogtreecommitdiff
path: root/tests/import
diff options
context:
space:
mode:
Diffstat (limited to 'tests/import')
-rw-r--r--tests/import/builtin_import.py16
-rw-r--r--tests/import/pkg7/subpkg1/subpkg2/mod3.py3
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/import/builtin_import.py b/tests/import/builtin_import.py
new file mode 100644
index 000000000..088f631fc
--- /dev/null
+++ b/tests/import/builtin_import.py
@@ -0,0 +1,16 @@
+# test calling builtin import function
+
+# basic test
+__import__('builtins')
+
+# first arg should be a string
+try:
+ __import__(1)
+except TypeError:
+ print('TypeError')
+
+# level argument should be non-negative
+try:
+ __import__('xyz', None, None, None, -1)
+except ValueError:
+ print('ValueError')
diff --git a/tests/import/pkg7/subpkg1/subpkg2/mod3.py b/tests/import/pkg7/subpkg1/subpkg2/mod3.py
index 7ed69bdee..c73e2081f 100644
--- a/tests/import/pkg7/subpkg1/subpkg2/mod3.py
+++ b/tests/import/pkg7/subpkg1/subpkg2/mod3.py
@@ -3,8 +3,7 @@ from ...mod2 import bar
print(mod1.foo)
print(bar)
-# when attempting relative import beyond top-level package uPy raises ImportError
-# whereas CPython raises a ValueError
+# attempted relative import beyond top-level package
try:
from .... import mod1
except ValueError: