summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--six.py6
-rw-r--r--test_six.py14
2 files changed, 19 insertions, 1 deletions
diff --git a/six.py b/six.py
index 3887a06..9a8a9a3 100644
--- a/six.py
+++ b/six.py
@@ -104,6 +104,10 @@ class MovedModule(_LazyDescr):
def _resolve(self):
return _import_module(self.mod)
+ def __getattr__(self, attr):
+ _module = self._resolve()
+ return getattr(_module, attr)
+
class _LazyModule(types.ModuleType):
@@ -212,6 +216,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
_MovedItems._moved_attributes = _moved_attributes
diff --git a/test_six.py b/test_six.py
index e6e75dd..14f0e7e 100644
--- a/test_six.py
+++ b/test_six.py
@@ -96,7 +96,9 @@ except ImportError:
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+")
@@ -183,6 +185,16 @@ def test_import_moves_error_3():
from six.moves.urllib_parse import urljoin
+def test_from_six_moves_queue_import_Queue():
+ from six.moves.queue import Queue
+ assert isinstance(Queue, types.ClassType)
+
+
+def test_from_six_moves_configparser_import_ConfigParser():
+ from six.moves.configparser import ConfigParser
+ assert isinstance(ConfigParser, types.ClassType)
+
+
def test_filter():
from six.moves import filter
f = filter(lambda x: x % 2, range(10))