diff options
author | Rami Ali <flowergrass@users.noreply.github.com> | 2017-01-16 15:45:55 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-01-16 15:59:33 +1100 |
commit | 50e14ca61945dcb5487e1b54d99fc84c530a32f7 (patch) | |
tree | da48c943ad40f14b84a2f25a6596dbe00c5d4cc4 /tests/import | |
parent | 8d01bd3a1cd00fa50017ef1d95f8f66e0b7a6365 (diff) | |
download | micropython-50e14ca61945dcb5487e1b54d99fc84c530a32f7.tar.gz micropython-50e14ca61945dcb5487e1b54d99fc84c530a32f7.zip |
tests/import: Improve builtinimport.c test coverage.
Diffstat (limited to 'tests/import')
-rw-r--r-- | tests/import/import_pkg7.py | 2 | ||||
-rw-r--r-- | tests/import/import_pkg8.py | 2 | ||||
-rw-r--r-- | tests/import/pkg7/subpkg1/subpkg2/mod3.py | 7 | ||||
-rw-r--r-- | tests/import/pkg8/mod.py | 1 |
4 files changed, 11 insertions, 1 deletions
diff --git a/tests/import/import_pkg7.py b/tests/import/import_pkg7.py index be8564ef66..e1463ebbf8 100644 --- a/tests/import/import_pkg7.py +++ b/tests/import/import_pkg7.py @@ -1,2 +1,2 @@ -# This tests ... relative imports as used in pkg7 +# This tests ... relative imports as used in pkg7 and imports beyond package root import pkg7.subpkg1.subpkg2.mod3 diff --git a/tests/import/import_pkg8.py b/tests/import/import_pkg8.py new file mode 100644 index 0000000000..4c1e832f2c --- /dev/null +++ b/tests/import/import_pkg8.py @@ -0,0 +1,2 @@ +# import with no __init__.py files +import pkg8.mod diff --git a/tests/import/pkg7/subpkg1/subpkg2/mod3.py b/tests/import/pkg7/subpkg1/subpkg2/mod3.py index b85b34e604..747cde03b6 100644 --- a/tests/import/pkg7/subpkg1/subpkg2/mod3.py +++ b/tests/import/pkg7/subpkg1/subpkg2/mod3.py @@ -2,3 +2,10 @@ from ... import mod1 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 +try: + from .... import mod1 +except (ImportError, ValueError): + print('Error') diff --git a/tests/import/pkg8/mod.py b/tests/import/pkg8/mod.py new file mode 100644 index 0000000000..b98f02ce6e --- /dev/null +++ b/tests/import/pkg8/mod.py @@ -0,0 +1 @@ +print('foo') |