diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-05-12 17:03:14 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-06-01 16:21:37 +1000 |
commit | 5e0452125146f3afed89c09f5813790156d24471 (patch) | |
tree | 7c8226caf407554a8d5fc7c5a78ac056c9c82e71 /tests/unix/extra_coverage.py | |
parent | 6a8114eee8ff486d812b4efc5a94880b565640f3 (diff) |
examples/usercmodule: Add a sub-package example.
This demonstrates how to add a sub-package in a user c module, as well
as how to define the necessary qstrs and enable the feature in the build.
This is used by the unix coverage build to test this feature.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/unix/extra_coverage.py')
-rw-r--r-- | tests/unix/extra_coverage.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py index a51b5b856..3c12b2692 100644 --- a/tests/unix/extra_coverage.py +++ b/tests/unix/extra_coverage.py @@ -96,3 +96,20 @@ print(returns_NULL()) import frozentest print(frozentest.__file__) + +# test for builtin sub-packages +from example_package.foo import bar + +print(bar) +bar.f() +import example_package + +print(example_package, example_package.foo, example_package.foo.bar) +example_package.f() +example_package.foo.f() +example_package.foo.bar.f() +print(bar == example_package.foo.bar) +from example_package.foo import f as foo_f + +foo_f() +print(foo_f == example_package.foo.f) |