'Deprecating an attribute in a module replaces and wraps that module
instance, in C{sys.modules}, with a
L{twisted.python.deprecate._ModuleProxy} instance but only if it hasn\'t
already been wrapped.'

def test_wrappedModule(self):

    sys.modules[self._testModuleName] = mod = types.ModuleType('foo')
    self.addCleanup(sys.modules.pop, self._testModuleName)
    setattr(mod, 'first', 1)
    setattr(mod, 'second', 2)
    deprecate.deprecatedModuleAttribute(Version('Twisted', 8, 0, 0), 'message', self._testModuleName, 'first')
    proxy = sys.modules[self._testModuleName]
    self.assertNotEqual(proxy, mod)
    deprecate.deprecatedModuleAttribute(Version('Twisted', 8, 0, 0), 'message', self._testModuleName, 'second')
    self.assertIs(proxy, sys.modules[self._testModuleName])
