99a0c45aef
When foo.bar is imported, bar is added as an attribute to foo. Previously this happened on every import, but should only happen on first import. This verifies the behavior for relative imports and overriding. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
17 lines
231 B
Python
17 lines
231 B
Python
# 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__)
|