Exemplo n.º 1
0
  def testDefineModule(self):
    """Test define_module function."""
    file_descriptor = self.MakeFileDescriptor('my.package')

    module = definition.define_file(file_descriptor)

    self.assertEquals('my.package', module.__name__)
    self.assertEquals('my.package', module.MyEnum.__module__)
    self.assertEquals('my.package', module.MyMessage.__module__)
    self.assertEquals('my.package', module.MyService.__module__)

    self.assertEquals(file_descriptor, descriptor.describe_file(module))
Exemplo n.º 2
0
    def testDefineModule(self):
        """Test define_module function."""
        file_descriptor = self.MakeFileDescriptor('my.package')

        module = definition.define_file(file_descriptor)

        self.assertEquals('my.package', module.__name__)
        self.assertEquals('my.package', module.MyEnum.__module__)
        self.assertEquals('my.package', module.MyMessage.__module__)
        self.assertEquals('my.package', module.MyService.__module__)

        self.assertEquals(file_descriptor, descriptor.describe_file(module))
Exemplo n.º 3
0
  def testDefineModule_ReuseModule(self):
    """Test updating module with additional definitions."""
    file_descriptor = self.MakeFileDescriptor('my.package')

    module = types.ModuleType('override')
    self.assertEquals(module, definition.define_file(file_descriptor, module))

    self.assertEquals('override', module.MyEnum.__module__)
    self.assertEquals('override', module.MyMessage.__module__)
    self.assertEquals('override', module.MyService.__module__)

    # One thing is different between original descriptor and new.
    file_descriptor.package = 'override'
    self.assertEquals(file_descriptor, descriptor.describe_file(module))
Exemplo n.º 4
0
    def testDefineModule_ReuseModule(self):
        """Test updating module with additional definitions."""
        file_descriptor = self.MakeFileDescriptor('my.package')

        module = types.ModuleType('override')
        self.assertEquals(module,
                          definition.define_file(file_descriptor, module))

        self.assertEquals('override', module.MyEnum.__module__)
        self.assertEquals('override', module.MyMessage.__module__)
        self.assertEquals('override', module.MyService.__module__)

        # One thing is different between original descriptor and new.
        file_descriptor.package = 'override'
        self.assertEquals(file_descriptor, descriptor.describe_file(module))