diff --git a/tests/import/import_pkg9.py b/tests/import/import_pkg9.py new file mode 100644 index 0000000000..4de028494f --- /dev/null +++ b/tests/import/import_pkg9.py @@ -0,0 +1,16 @@ +# tests that import only sets subpackage attribute on first import + +import pkg9 + +pkg9.mod1() +pkg9.mod2() + +import pkg9.mod1 + +pkg9.mod1() +pkg9.mod2() + +import pkg9.mod2 + +pkg9.mod1() +print(pkg9.mod2.__name__, type(pkg9.mod2).__name__) diff --git a/tests/import/pkg9/__init__.py b/tests/import/pkg9/__init__.py new file mode 100644 index 0000000000..5d08d4b4a9 --- /dev/null +++ b/tests/import/pkg9/__init__.py @@ -0,0 +1,5 @@ +from .mod1 import mod1 + + +def mod2(): + print("mod2") diff --git a/tests/import/pkg9/mod1.py b/tests/import/pkg9/mod1.py new file mode 100644 index 0000000000..7e7066bada --- /dev/null +++ b/tests/import/pkg9/mod1.py @@ -0,0 +1,2 @@ +def mod1(): + print("mod1") diff --git a/tests/import/pkg9/mod2.py b/tests/import/pkg9/mod2.py new file mode 100644 index 0000000000..f4b3e265fb --- /dev/null +++ b/tests/import/pkg9/mod2.py @@ -0,0 +1 @@ +from . import mod2