当前位置: 首页>>代码示例>>Python>>正文


Python deprecate.getDeprecationWarningString函数代码示例

本文整理汇总了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)
开发者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


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