summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2013-09-07 10:19:05 -0700
committerMarc Abramowitz <marc@marc-abramowitz.com>2013-09-07 10:19:05 -0700
commitc97fb65a16dca879b9d215cb6ed1ffdc93c8ef20 (patch)
treef2687423e7458fd5e1899d12e72ba54a88badfaa
parent49b5fcc7e024c204db4983a213e1bfddbdf0a9d8 (diff)
downloadsix-c97fb65a16dca879b9d215cb6ed1ffdc93c8ef20.tar.gz
Put six.moves modules in sys.modules so that they're importable (fixes
#19)
-rw-r--r--six.py2
-rw-r--r--test_six.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/six.py b/six.py
index 85898ec..f622c20 100644
--- a/six.py
+++ b/six.py
@@ -193,6 +193,8 @@ _moved_attributes = [
]
for attr in _moved_attributes:
setattr(_MovedItems, attr.name, attr)
+ if isinstance(attr, MovedModule):
+ sys.modules[__name__ + ".moves." + attr.name] = attr
del attr
moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves")
diff --git a/test_six.py b/test_six.py
index 81d1776..b2ffe84 100644
--- a/test_six.py
+++ b/test_six.py
@@ -89,7 +89,9 @@ else:
def test_move_items(item_name):
"""Ensure that everything loads correctly."""
try:
- getattr(six.moves, item_name)
+ item = getattr(six.moves, item_name)
+ if isinstance(item, types.ModuleType):
+ __import__("six.moves." + item_name)
except AttributeError:
if item_name == "zip_longest" and sys.version_info < (2, 6):
py.test.skip("zip_longest only available on 2.6+")