Import priorities are wrong (__dict__ > files). Test for #536.

This commit is contained in:
Dave Halter
2015-04-13 15:04:49 +02:00
parent e2455eb670
commit bc765979ca
3 changed files with 24 additions and 1 deletions

View File

@@ -1 +1,7 @@
a = ''
from . import invisible_pkg
the_pkg = invisible_pkg
invisible_pkg = 1

View File

@@ -110,6 +110,23 @@ def as_imports():
#? int()
bar.a
def test_import_priorities():
"""
It's possible to overwrite import paths in an ``__init__.py`` file, by
just assigining something there.
See also #536.
"""
from import_tree import the_pkg, invisible_pkg
# TODO currently not enabled, later we should actually fix this.
##? int()
invisible_pkg
# The renamed invisible_pkg in that module (look at ``__init__.py``!)
#? float()
the_pkg.foo
# -----------------
# std lib modules
# -----------------

View File

@@ -65,7 +65,7 @@ import datetime.date
from import_tree.pkg import pkg
#? 22 ['mod1']
from import_tree.pkg. import mod1
#? 17 ['mod1', 'mod2', 'random', 'pkg', 'rename1', 'rename2', 'recurse_class1', 'recurse_class2']
#? 17 ['mod1', 'mod2', 'random', 'pkg', 'rename1', 'rename2', 'recurse_class1', 'recurse_class2', 'invisible_pkg']
from import_tree. import pkg
#? 18 ['pkg']