1 parent 8d01bd3 commit 50e14caCopy full SHA for 50e14ca
4 files changed
tests/import/import_pkg7.py
@@ -1,2 +1,2 @@
1
-# This tests ... relative imports as used in pkg7
+# This tests ... relative imports as used in pkg7 and imports beyond package root
2
import pkg7.subpkg1.subpkg2.mod3
tests/import/import_pkg8.py
@@ -0,0 +1,2 @@
+# import with no __init__.py files
+import pkg8.mod
tests/import/pkg7/subpkg1/subpkg2/mod3.py
@@ -2,3 +2,10 @@
from ...mod2 import bar
3
print(mod1.foo)
4
print(bar)
5
+
6
+# when attempting relative import beyond top-level package uPy raises ImportError
7
+# whereas CPython raises a ValueError
8
+try:
9
+ from .... import mod1
10
+except (ImportError, ValueError):
11
+ print('Error')
tests/import/pkg8/mod.py
@@ -0,0 +1 @@
+print('foo')
0 commit comments