• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python deprecate.getDeprecationWarningString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.python.deprecate.getDeprecationWarningString函数的典型用法代码示例。如果您正苦于以下问题:Python getDeprecationWarningString函数的具体用法?Python getDeprecationWarningString怎么用?Python getDeprecationWarningString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getDeprecationWarningString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:Bobboya,项目名称:vizitown_plugin,代码行数:7,代码来源:tap2rpm.py


示例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)))
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_script.py


示例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)
开发者ID:GunioRobot,项目名称:twisted,代码行数:10,代码来源:tap.py


示例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)))
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:10,代码来源:test_deprecate.py


示例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))
开发者ID:0004c,项目名称:VTK,代码行数:10,代码来源:ftp.py


示例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)
开发者ID:GunioRobot,项目名称:twisted,代码行数:12,代码来源:trial.py


示例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")
开发者ID:Almad,项目名称:twisted,代码行数:12,代码来源:test_deprecate.py


示例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)
开发者ID:williamsjj,项目名称:twisted,代码行数:12,代码来源:test_options.py


示例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
开发者ID:relaunched,项目名称:twisted,代码行数:12,代码来源:tcp.py


示例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__,))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:13,代码来源:test_deprecate.py


示例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)
开发者ID:Almad,项目名称:twisted,代码行数:13,代码来源:test_deprecate.py


示例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
开发者ID:Architektor,项目名称:PySnip,代码行数:50,代码来源:_synctest.py


示例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)
开发者ID:antong,项目名称:twisted,代码行数:14,代码来源:test_options.py


示例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))
开发者ID:Architektor,项目名称:PySnip,代码行数:14,代码来源:test_tap2rpm.py


示例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')
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:14,代码来源:test_deprecate.py


示例16: 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()
     with catch_warnings(record=True) as caught:
         simplefilter("always")
         addStackLevel()
         self.assertEqual(caught[0].category, DeprecationWarning)
         self.assertEqual(str(caught[0].message), getDeprecationWarningString(dummyCallable, version))
         # rstrip in case .pyc/.pyo
         self.assertEqual(caught[0].filename.rstrip('co'), __file__.rstrip('co'))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:15,代码来源:test_deprecate.py


示例17: test_getDeprecationWarningStringReplacement

 def test_getDeprecationWarningStringReplacement(self):
     """
     L{getDeprecationWarningString} takes an additional replacement parameter
     that can be used to add information to the deprecation.  If the
     replacement parameter is a string, it will be interpolated directly into
     the result.
     """
     version = Version('Twisted', 8, 0, 0)
     warningString = getDeprecationWarningString(
         self.test_getDeprecationWarningString, version,
         replacement="something.foobar")
     self.assertEqual(
         warningString,
         "%s was deprecated in Twisted 8.0.0; please use something.foobar "
         "instead" % (
             fullyQualifiedName(self.test_getDeprecationWarningString),))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:16,代码来源:test_deprecate.py


示例18: test_getDeprecationWarningStringReplacementWithCallable

 def test_getDeprecationWarningStringReplacementWithCallable(self):
     """
     L{getDeprecationWarningString} takes an additional replacement parameter
     that can be used to add information to the deprecation. If the
     replacement parameter is a callable, its fully qualified name will be
     interpolated into the result.
     """
     version = Version('Twisted', 8, 0, 0)
     warningString = getDeprecationWarningString(
         self.test_getDeprecationWarningString, version,
         replacement=dummyReplacementMethod)
     self.assertEqual(
         warningString,
         "%s was deprecated in Twisted 8.0.0; please use "
         "%s.dummyReplacementMethod instead" % (
             fullyQualifiedName(self.test_getDeprecationWarningString),
             __name__))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:17,代码来源:test_deprecate.py


示例19: __init__

    def __init__(self, keyObject):
        """
        Initialize with a private or public
        C{cryptography.hazmat.primitives.asymmetric} key.

        @param keyObject: Low level key.
        @type keyObject: C{cryptography.hazmat.primitives.asymmetric} key.
        """
        # Avoid importing PyCrypto if at all possible
        if keyObject.__class__.__module__.startswith('Crypto.PublicKey'):
            warningString = getDeprecationWarningString(
                Key,
                Version("Twisted", 16, 0, 0),
                replacement='passing a cryptography key object')
            warnings.warn(warningString, DeprecationWarning, stacklevel=2)
            self.keyObject = keyObject
        else:
            self._keyObject = keyObject
开发者ID:daweasel27,项目名称:PhobiaEnemy,代码行数:18,代码来源:keys.py


示例20: callDeprecated

    def callDeprecated(self, version, f, *args, **kwargs):
        """
        Call a function that was deprecated at a specific version.

        @param version: The version that the function was deprecated in.
        @param f: The deprecated function to call.
        @return: Whatever the function returns.
        """
        warnings, result = self._captureDeprecationWarnings(
            f, *args, **kwargs)

        if len(warnings) == 0:
            self.fail('%r is not deprecated.' % (f,))

        observedWarning = warnings[0]
        expectedWarning = getDeprecationWarningString(f, version)
        self.assertEqual(expectedWarning, observedWarning)

        return result
开发者ID:radical-software,项目名称:radicalspam,代码行数:19,代码来源:unittest.py



注:本文中的twisted.python.deprecate.getDeprecationWarningString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dist.getScripts函数代码示例发布时间:2022-05-27
下一篇:
Python deprecate.deprecatedModuleAttribute函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap