本文整理汇总了Python中twisted.python.deprecate.getDeprecationWarningString函数的典型用法代码示例。如果您正苦于以下问题:Python getDeprecationWarningString函数的具体用法?Python getDeprecationWarningString怎么用?Python getDeprecationWarningString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDeprecationWarningString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: opt_unsigned
def opt_unsigned(self):
"""
Generate an unsigned rather than a signed RPM. (DEPRECATED; unsigned
is the default)
"""
msg = deprecate.getDeprecationWarningString(self.opt_unsigned, versions.Version("Twisted", 12, 1, 0))
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
示例2: assertDeprecationWarning
def assertDeprecationWarning(self, deprecatedCallable, warnings):
"""
Check for a deprecation warning
"""
self.assertEquals(len(warnings), 1)
self.assertEquals(warnings[0]['category'], DeprecationWarning)
self.assertEquals(warnings[0]['message'],
deprecate.getDeprecationWarningString(
deprecatedCallable, versions.Version('Twisted', 11, 0, 0)))
示例3: opt_passwordfile
def opt_passwordfile(self, filename):
"""
Specify a file containing username:password login info for authenticated
ESMTP connections. (DEPRECATED; see --help-auth instead)
"""
ch = checkers.OnDiskUsernamePasswordDatabase(filename)
self.service.smtpPortal.registerChecker(ch)
msg = deprecate.getDeprecationWarningString(
self.opt_passwordfile, versions.Version('twisted.mail', 11, 0, 0))
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
示例4: test_getDeprecationWarningString
def test_getDeprecationWarningString(self):
"""
L{getDeprecationWarningString} returns a string that tells us that a
callable was deprecated at a certain released version of Twisted.
"""
version = Version('Twisted', 8, 0, 0)
self.assertEqual(
getDeprecationWarningString(self.test_getDeprecationWarningString, version),
"%s was deprecated in Twisted 8.0.0" % (
qual(self.test_getDeprecationWarningString)))
示例5: opt_password_file
def opt_password_file(self, filename):
"""
Specify a file containing username:password login info for
authenticated connections. (DEPRECATED; see --help-auth instead)
"""
self['password-file'] = filename
msg = deprecate.getDeprecationWarningString(
self.opt_password_file, versions.Version('Twisted', 11, 1, 0))
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
self.addChecker(checkers.FilePasswordDB(filename, cache=True))
示例6: opt_extra
def opt_extra(self, arg):
"""
Add an extra argument. (This is a hack necessary for interfacing with
emacs's `gud'.) NOTE: This option is deprecated as of Twisted 11.0
"""
warnings.warn(deprecate.getDeprecationWarningString(Options.opt_extra,
versions.Version('Twisted', 11, 0, 0)),
category=DeprecationWarning, stacklevel=2)
if self.extra is None:
self.extra = []
self.extra.append(arg)
示例7: test_getDeprecationWarningString
def test_getDeprecationWarningString(self):
"""
L{getDeprecationWarningString} returns a string that tells us that a
callable was deprecated at a certain released version of Twisted.
"""
version = Version('Twisted', 8, 0, 0)
self.assertEqual(
getDeprecationWarningString(self.test_getDeprecationWarningString,
version),
"twisted.python.test.test_deprecate.TestDeprecationWarnings."
"test_getDeprecationWarningString was deprecated in "
"Twisted 8.0.0")
示例8: testPasswordfileDeprecation
def testPasswordfileDeprecation(self):
"""
Test that the --passwordfile option will emit a correct warning.
"""
options = Options()
options.opt_passwordfile('/dev/null')
warnings = self.flushWarnings([self.testPasswordfileDeprecation])
self.assertEquals(warnings[0]['category'], DeprecationWarning)
self.assertEquals(len(warnings), 1)
msg = deprecate.getDeprecationWarningString(options.opt_passwordfile,
versions.Version('twisted.mail', 11, 0, 0))
self.assertEquals(warnings[0]['message'], msg)
示例9: _dataReceived
def _dataReceived(self, data):
if not data:
return main.CONNECTION_DONE
rval = self.protocol.dataReceived(data)
if rval is not None:
offender = self.protocol.dataReceived
warningFormat = "Returning a value other than None from %(fqpn)s is " "deprecated since %(version)s."
warningString = deprecate.getDeprecationWarningString(
offender, versions.Version("Twisted", 11, 0, 0), format=warningFormat
)
deprecate.warnAboutFunction(offender, warningString)
return rval
示例10: test_getDeprecationWarningStringWithFormat
def test_getDeprecationWarningStringWithFormat(self):
"""
L{getDeprecationWarningString} returns a string that tells us that a
callable was deprecated at a certain released version of Twisted, with
a message containing additional information about the deprecation.
"""
version = Version('Twisted', 8, 0, 0)
format = DEPRECATION_WARNING_FORMAT + ': This is a message'
self.assertEqual(
getDeprecationWarningString(self.test_getDeprecationWarningString,
version, format),
'%s.DeprecationWarningsTests.test_getDeprecationWarningString was '
'deprecated in Twisted 8.0.0: This is a message' % (__name__,))
示例11: test_deprecateEmitsWarning
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)
示例12: callDeprecated
def callDeprecated(self, version, f, *args, **kwargs):
"""
Call a function that should have been deprecated at a specific version
and in favor of a specific alternative, and assert that it was thusly
deprecated.
@param version: A 2-sequence of (since, replacement), where C{since} is
a the first L{version<twisted.python.versions.Version>} that C{f}
should have been deprecated since, and C{replacement} is a suggested
replacement for the deprecated functionality, as described by
L{twisted.python.deprecate.deprecated}. If there is no suggested
replacement, this parameter may also be simply a
L{version<twisted.python.versions.Version>} by itself.
@param f: The deprecated function to call.
@param args: The arguments to pass to C{f}.
@param kwargs: The keyword arguments to pass to C{f}.
@return: Whatever C{f} returns.
@raise: Whatever C{f} raises. If any exception is
raised by C{f}, though, no assertions will be made about emitted
deprecations.
@raise FailTest: if no warnings were emitted by C{f}, or if the
L{DeprecationWarning} emitted did not produce the canonical
please-use-something-else message that is standard for Twisted
deprecations according to the given version and replacement.
"""
result = f(*args, **kwargs)
warningsShown = self.flushWarnings([self.callDeprecated])
try:
info = list(version)
except TypeError:
since = version
replacement = None
else:
[since, replacement] = info
if len(warningsShown) == 0:
self.fail('%r is not deprecated.' % (f,))
observedWarning = warningsShown[0]['message']
expectedWarning = getDeprecationWarningString(
f, since, replacement=replacement)
self.assertEqual(expectedWarning, observedWarning)
return result
示例13: testPasswordfileDeprecation
def testPasswordfileDeprecation(self):
"""
Test that the --passwordfile option will emit a correct warning.
"""
passwd = FilePath(self.mktemp())
passwd.setContent("")
options = Options()
options.opt_passwordfile(passwd.path)
warnings = self.flushWarnings([self.testPasswordfileDeprecation])
self.assertEqual(warnings[0]['category'], DeprecationWarning)
self.assertEqual(len(warnings), 1)
msg = deprecate.getDeprecationWarningString(options.opt_passwordfile,
versions.Version('twisted.mail', 11, 0, 0))
self.assertEqual(warnings[0]['message'], msg)
示例14: test_unsignedFlagDeprecationWarning
def test_unsignedFlagDeprecationWarning(self):
"""
The 'unsigned' flag in tap2rpm should be deprecated, and its use
should raise a warning as such.
"""
config = tap2rpm.MyOptions()
config.parseOptions(['--unsigned'])
warnings = self.flushWarnings()
self.assertEqual(DeprecationWarning, warnings[0]['category'])
self.assertEqual(
deprecate.getDeprecationWarningString(
config.opt_unsigned, versions.Version("Twisted", 12, 1, 0)),
warnings[0]['message'])
self.assertEqual(1, len(warnings))
示例15: test_getDeprecationWarningStringWithFormat
def test_getDeprecationWarningStringWithFormat(self):
"""
L{getDeprecationWarningString} returns a string that tells us that a
callable was deprecated at a certain released version of Twisted, with
a message containing additional information about the deprecation.
"""
version = Version('Twisted', 8, 0, 0)
format = deprecate.DEPRECATION_WARNING_FORMAT + ': This is a message'
self.assertEquals(
getDeprecationWarningString(self.test_getDeprecationWarningString,
version, format),
'twisted.python.test.test_deprecate.TestDeprecationWarnings.'
'test_getDeprecationWarningString was deprecated in '
'Twisted 8.0.0: This is a message')