summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/import/import_pkg9.py16
-rw-r--r--tests/import/pkg9/__init__.py5
-rw-r--r--tests/import/pkg9/mod1.py2
-rw-r--r--tests/import/pkg9/mod2.py1
4 files changed, 24 insertions, 0 deletions
diff --git a/tests/import/import_pkg9.py b/tests/import/import_pkg9.py
new file mode 100644
index 000000000..4de028494
--- /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 000000000..5d08d4b4a
--- /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 000000000..7e7066bad
--- /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 000000000..f4b3e265f
--- /dev/null
+++ b/tests/import/pkg9/mod2.py
@@ -0,0 +1 @@
+from . import mod2