def __setattr__(self, name, submodule):
self._builder._add_submodule(submodule, name)
+ def __setitem__(self, name, value):
+ return self.__setattr__(name, value)
+
class _ModuleBuilderDomainSet:
def __init__(self, builder):
m1.submodules.foo = m2
self.assertEqual(m1._submodules, [(m2, "foo")])
+ def test_submodule_named_index(self):
+ m1 = Module()
+ m2 = Module()
+ m1.submodules["foo"] = m2
+ self.assertEqual(m1._submodules, [(m2, "foo")])
+
def test_submodule_wrong(self):
m = Module()
with self.assertRaises(TypeError,