def test_versionMetadata(self): """ Deprecating a function adds version information to the decorated version of that function. """ version = Version('Twisted', 8, 0, 0) dummy = deprecated(version)(dummyCallable) self.assertEqual(version, dummy.deprecatedVersion)
def test_deprecatedPreservesName(self): """ The decorated function has the same name as the original. """ version = Version('Twisted', 8, 0, 0) dummy = deprecated(version)(dummyCallable) self.assertEqual(dummyCallable.__name__, dummy.__name__) self.assertEqual(fullyQualifiedName(dummyCallable), fullyQualifiedName(dummy))
def test_deprecatedUpdatesDocstring(self): """ The docstring of the deprecated function is appended with information about the deprecation. """ version = Version('Twisted', 8, 0, 0) dummy = deprecated(version)(dummyCallable) _appendToDocstring(dummyCallable, _getDeprecationDocstring(version)) self.assertEqual(dummyCallable.__doc__, dummy.__doc__)
def test_deprecateEmitsWarning(self): """ Decorating a callable with L{deprecated} emits a warning. """ version = Version('Twisted', 8, 0, 0) dummy = deprecated(version)(dummyCallable) def addStackLevel(): dummy() self.assertWarns( DeprecationWarning, getDeprecationWarningString(dummyCallable, version), __file__, addStackLevel)
def test_deprecateEmitsWarning(self): """ Decorating a callable with L{deprecated} emits a warning. """ version = Version('Twisted', 8, 0, 0) dummy = deprecated(version)(dummyCallable) def addStackLevel(): dummy() self.assertWarns(DeprecationWarning, getDeprecationWarningString(dummyCallable, version), __file__, addStackLevel)
def test_deprecatedUpdatesDocstring(self): """ The docstring of the deprecated function is appended with information about the deprecation. """ version = Version('Twisted', 8, 0, 0) dummy = deprecated(version)(dummyCallable) _appendToDocstring( dummyCallable, _getDeprecationDocstring(version)) self.assertEqual(dummyCallable.__doc__, dummy.__doc__)
m.update(pszRealm) m.update(":") m.update(pszPassword) HA1 = m.digest() if pszAlg == "md5-sess": m = md5() m.update(HA1) m.update(":") m.update(pszNonce) m.update(":") m.update(pszCNonce) HA1 = m.digest() return HA1.encode('hex') DigestCalcHA1 = deprecated(Version("Twisted", 9, 0, 0))(DigestCalcHA1) def DigestCalcResponse( HA1, pszNonce, pszNonceCount, pszCNonce, pszQop, pszMethod, pszDigestUri, pszHEntity, ): m = md5() m.update(pszMethod) m.update(":") m.update(pszDigestUri)
tprmm = tprm + '.' + macroname mymod = new.module(tprmm) sys.modules[tprmm] = mymod setattr(macros, macroname, mymod) dict = mymod.__dict__ # Before we go on, I guess I should explain why I just did that. Basically # it's a gross hack to get epydoc to work right, but the general idea is # that it will be a useful aid in debugging in _any_ app which expects # sys.modules to have the same globals as some function. For example, it # would be useful if you were foolishly trying to pickle a wrapped function # directly from a class that had been hooked. exec code in dict, dict return dict[name] macro = deprecated(Version("Twisted", 8, 2, 0))(macro) def _determineClass(x): try: return x.__class__ except: return type(x) def _determineClassName(x): c = _determineClass(x) try: return c.__name__
m.update(pszRealm) m.update(":") m.update(pszPassword) HA1 = m.digest() if pszAlg == "md5-sess": m = md5() m.update(HA1) m.update(":") m.update(pszNonce) m.update(":") m.update(pszCNonce) HA1 = m.digest() return HA1.encode('hex') DigestCalcHA1 = deprecated(Version("Twisted", 9, 0, 0))(DigestCalcHA1) def DigestCalcResponse( HA1, pszNonce, pszNonceCount, pszCNonce, pszQop, pszMethod, pszDigestUri, pszHEntity, ): m = md5() m.update(pszMethod) m.update(":")
sys.modules[tprmm] = mymod setattr(macros, macroname, mymod) dict = mymod.__dict__ # Before we go on, I guess I should explain why I just did that. Basically # it's a gross hack to get epydoc to work right, but the general idea is # that it will be a useful aid in debugging in _any_ app which expects # sys.modules to have the same globals as some function. For example, it # would be useful if you were foolishly trying to pickle a wrapped function # directly from a class that had been hooked. exec code in dict, dict return dict[name] macro = deprecated(Version("Twisted", 8, 2, 0))(macro) def _determineClass(x): try: return x.__class__ except: return type(x) def _determineClassName(x): c = _determineClass(x) try: return c.__name__ except: try: