This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 25a2a42f authored by Alex Gaynor's avatar Alex Gaynor
Browse files

Actually set the attribute for the submodule on the parent module, fixes both that and importing.

parent 80c461c9a885
......@@ -31,11 +31,13 @@ class MixedModule(Module):
if hasattr(self, "submodules"):
name =
space =
name = space.unwrap(self.w_name)
for sub_name, module_cls in self.submodules.iteritems():
module_name ="%s.%s" % (name, sub_name))
m = module_cls(, module_name)
module_name = space.wrap("%s.%s" % (name, sub_name))
m = module_cls(space, module_name)
space.setitem(self.w_dict, space.wrap(sub_name), space.wrap(m))
def init(self, space):
"""This is called each time the module is imported or reloaded
......@@ -29,3 +29,29 @@ class TestMixedModule(object):
assert["test_module"] is m
assert isinstance(["test_module.sub"], SubModule)
class AppTestMixedModule(object):
def setup_class(cls):
space =
class SubModule(MixedModule):
interpleveldefs = {}
appleveldefs = {}
class Module(MixedModule):
interpleveldefs = {}
appleveldefs = {}
submodules = {
"sub": SubModule
m = Module(space, space.wrap("test_module"))
def test_attibute(self):
import test_module
assert hasattr(test_module, "sub")
def test_submodule_import(self):
from test_module import sub
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment