Skip to content

Commit 50e14ca

Browse files
flowergrassdpgeorge
authored andcommitted
tests/import: Improve builtinimport.c test coverage.
1 parent 8d01bd3 commit 50e14ca

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

tests/import/import_pkg7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# This tests ... relative imports as used in pkg7
1+
# This tests ... relative imports as used in pkg7 and imports beyond package root
22
import pkg7.subpkg1.subpkg2.mod3

tests/import/import_pkg8.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# import with no __init__.py files
2+
import pkg8.mod

tests/import/pkg7/subpkg1/subpkg2/mod3.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
from ...mod2 import bar
33
print(mod1.foo)
44
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print('foo')

0 commit comments

Comments
 (0)