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

Python testutils.tokenize_str函数代码示例

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

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



在下文中一共展示了tokenize_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testTrailingCommaGood

    def testTrailingCommaGood(self):
        with self.assertNoMessages():
            self.checker.process_tokens(tokenize_str('(a, )\n'))
            self.checker.process_tokens(tokenize_str('(a,)\n'))

        self.checker.config.no_space_check = []
        with self.assertNoMessages():
            self.checker.process_tokens(tokenize_str('(a,)\n'))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:8,代码来源:unittest_checker_format.py


示例2: testEmptyLines

    def testEmptyLines(self):
        self.checker.config.no_space_check = []
        with self.assertAddsMessages(
            Message('trailing-whitespace', line=2)):
            self.checker.process_tokens(tokenize_str('a = 1\n  \nb = 2\n'))

        self.checker.config.no_space_check = ['empty-line']
        with self.assertNoMessages():
            self.checker.process_tokens(tokenize_str('a = 1\n  \nb = 2\n'))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:9,代码来源:unittest_checker_format.py


示例3: test_check_bad_coment

 def test_check_bad_coment(self):
     with self.assertAddsMessages(
         Message('wrong-spelling-in-comment', line=1,
                 args=('coment', '# bad coment',
                       '      ^^^^^^',
                       "comet' or 'comment' or 'moment' or 'foment"))):
         self.checker.process_tokens(tokenize_str("# bad coment"))
开发者ID:glennmatthews,项目名称:pylint,代码行数:7,代码来源:unittest_checker_spelling.py


示例4: test_check_bad_coment

 def test_check_bad_coment(self):
     suggestions = self.checker.spelling_dict.suggest('coment')[:4]
     with self.assertAddsMessages(
         Message('wrong-spelling-in-comment', line=1,
                 args=('coment', '# bad coment',
                       '      ^^^^^^',
                       "'{0}'".format("' or '".join(suggestions))))):
         self.checker.process_tokens(tokenize_str("# bad coment"))
开发者ID:pennyarcade,项目名称:py_pov,代码行数:8,代码来源:unittest_checker_spelling.py


示例5: testFuturePrintStatementWithoutParensWarning

    def testFuturePrintStatementWithoutParensWarning(self):
        code = """from __future__ import print_function
print('Hello world!')
"""
        tree = astroid.parse(code)
        with self.assertNoMessages():
            self.checker.process_module(tree)
            self.checker.process_tokens(tokenize_str(code))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:8,代码来源:unittest_checker_format.py


示例6: test_old_octal_literal

    def test_old_octal_literal(self):
        for octal in ("045", "055", "075", "077", "076543"):
            self._test_token_message(octal, "old-octal-literal")

        # Make sure we are catching only octals.
        for non_octal in ("45", "00", "085", "08", "1"):
            tokens = testutils.tokenize_str(non_octal)
            with self.assertNoMessages():
                self.checker.process_tokens(tokens)
开发者ID:Vauxoo,项目名称:pylint,代码行数:9,代码来源:unittest_checker_python3.py


示例7: testOperatorSpacingGood

 def testOperatorSpacingGood(self):
     good_cases = [
         'a = b\n'
         'a < b\n'
         'a\n< b\n',
         ]
     with self.assertNoMessages():
         for code in good_cases:
             self.checker.process_tokens(tokenize_str(code))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:9,代码来源:unittest_checker_format.py


示例8: testParenthesesGood

 def testParenthesesGood(self):
     good_cases = [
         '(a)\n',
         '(a * (b + c))\n',
         '(#\n    a)\n',
         ]
     with self.assertNoMessages():
         for code in good_cases:
             self.checker.process_tokens(tokenize_str(code))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:9,代码来源:unittest_checker_format.py


示例9: testKeywordSpacingBad

    def testKeywordSpacingBad(self):
        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'before', 'keyword argument assignment',
                          '(foo =bar)\n     ^'))):
            self.checker.process_tokens(tokenize_str('(foo =bar)\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'after', 'keyword argument assignment',
                          '(foo= bar)\n    ^'))):
            self.checker.process_tokens(tokenize_str('(foo= bar)\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'around', 'keyword argument assignment',
                          '(foo = bar)\n     ^'))):
            self.checker.process_tokens(tokenize_str('(foo = bar)\n'))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:18,代码来源:unittest_checker_format.py


示例10: testOperatorSpacingBad

    def testOperatorSpacingBad(self):
        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('Exactly one', 'required', 'before', 'comparison', 'a< b\n ^'))):
            self.checker.process_tokens(tokenize_str('a< b\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('Exactly one', 'required', 'after', 'comparison', 'a <b\n  ^'))):
            self.checker.process_tokens(tokenize_str('a <b\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('Exactly one', 'required', 'around', 'comparison', 'a<b\n ^'))):
            self.checker.process_tokens(tokenize_str('a<b\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('Exactly one', 'required', 'around', 'comparison', 'a<  b\n ^'))):
            self.checker.process_tokens(tokenize_str('a<  b\n'))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:20,代码来源:unittest_checker_format.py


示例11: testParenthesesBad

    def testParenthesesBad(self):
        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'after', 'bracket', '( a)\n^'))):
            self.checker.process_tokens(tokenize_str('( a)\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'before', 'bracket', '(a )\n   ^'))):
            self.checker.process_tokens(tokenize_str('(a )\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'before', 'bracket', 'foo (a)\n    ^'))):
            self.checker.process_tokens(tokenize_str('foo (a)\n'))

        with self.assertAddsMessages(
            Message('bad-whitespace', line=1,
                    args=('No', 'allowed', 'before', 'bracket', '{1: 2} [1]\n       ^'))):
            self.checker.process_tokens(tokenize_str('{1: 2} [1]\n'))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:20,代码来源:unittest_checker_format.py


示例12: testSpacesAllowedInsideSlices

 def testSpacesAllowedInsideSlices(self):
     good_cases = [
         '[a:b]\n',
         '[a : b]\n',
         '[a : ]\n',
         '[:a]\n',
         '[:]\n',
         '[::]\n',
         ]
     with self.assertNoMessages():
         for code in good_cases:
             self.checker.process_tokens(tokenize_str(code))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:12,代码来源:unittest_checker_format.py


示例13: testKeywordSpacingGood

 def testKeywordSpacingGood(self):
     with self.assertNoMessages():
         self.checker.process_tokens(tokenize_str('foo(foo=bar)\n'))
         self.checker.process_tokens(tokenize_str('foo(foo: int = bar)\n'))
         self.checker.process_tokens(tokenize_str('foo(foo: Dict[int, str] = bar)\n'))
         self.checker.process_tokens(tokenize_str('foo(foo: \'int\' = bar)\n'))
         self.checker.process_tokens(tokenize_str('foo(foo: Dict[int, \'str\'] = bar)\n'))
         self.checker.process_tokens(tokenize_str('lambda x=1: x\n'))
开发者ID:vauxoo-dev,项目名称:pylint,代码行数:8,代码来源:unittest_checker_format.py


示例14: testCheckKeywordParensHandlesValidCases

 def testCheckKeywordParensHandlesValidCases(self):
     self.checker._keywords_with_parens = set()
     cases = [
         'if foo:',
         'if foo():',
         'if (x and y) or z:',
         'assert foo()',
         'assert ()',
         'if (1, 2) in (3, 4):',
         'if (a or b) in c:',
         'return (x for x in x)',
         'if (x for x in x):',
         'for x in (x for x in x):',
         'not (foo or bar)',
         'not (foo or bar) and baz',
         ]
     with self.assertNoMessages():
         for code in cases:
             self.checker._check_keyword_parentheses(tokenize_str(code), 0)
开发者ID:DonJayamanne,项目名称:pylint,代码行数:19,代码来源:unittest_checker_format.py


示例15: testCheckKeywordParensHandlesUnnecessaryParens

 def testCheckKeywordParensHandlesUnnecessaryParens(self):
     self.checker._keywords_with_parens = set()
     cases = [
         (Message('superfluous-parens', line=1, args='if'),
          'if (foo):', 0),
         (Message('superfluous-parens', line=1, args='if'),
          'if ((foo, bar)):', 0),
         (Message('superfluous-parens', line=1, args='if'),
          'if (foo(bar)):', 0),
         (Message('superfluous-parens', line=1, args='return'),
          'return ((x for x in x))', 0),
         (Message('superfluous-parens', line=1, args='not'),
          'not (foo)', 0),
         (Message('superfluous-parens', line=1, args='not'),
          'if not (foo):', 1),
         (Message('superfluous-parens', line=1, args='if'),
          'if (not (foo)):', 0),
         (Message('superfluous-parens', line=1, args='not'),
          'if (not (foo)):', 2),
         ]
     for msg, code, offset in cases:
         with self.assertAddsMessages(msg):
             self.checker._check_keyword_parentheses(tokenize_str(code), offset)
开发者ID:DonJayamanne,项目名称:pylint,代码行数:23,代码来源:unittest_checker_format.py


示例16: test_skip_python_coding_comments

 def test_skip_python_coding_comments(self):
     self.checker.process_tokens(tokenize_str(
         '# -*- coding: utf-8 -*-'))
     assert self.linter.release_messages() == []
     self.checker.process_tokens(tokenize_str(
         '# coding=utf-8'))
     assert self.linter.release_messages() == []
     self.checker.process_tokens(tokenize_str(
         '# vim: set fileencoding=utf-8 :'))
     assert self.linter.release_messages() == []
     # Now with a shebang first
     self.checker.process_tokens(tokenize_str(
         '#!/usr/bin/env python\n# -*- coding: utf-8 -*-'))
     assert self.linter.release_messages() == []
     self.checker.process_tokens(tokenize_str(
         '#!/usr/bin/env python\n# coding=utf-8'))
     assert self.linter.release_messages() == []
     self.checker.process_tokens(tokenize_str(
         '#!/usr/bin/env python\n# vim: set fileencoding=utf-8 :'))
     assert self.linter.release_messages() == []
开发者ID:pennyarcade,项目名称:py_pov,代码行数:20,代码来源:unittest_checker_spelling.py


示例17: test_skip_email_address

 def test_skip_email_address(self):
     self.checker.process_tokens(tokenize_str('# [email protected]'))
     assert self.linter.release_messages() == []
开发者ID:pennyarcade,项目名称:py_pov,代码行数:3,代码来源:unittest_checker_spelling.py


示例18: testComma

 def testComma(self):
     with self.assertAddsMessages(
         Message('bad-whitespace', line=1,
                 args=('No', 'allowed', 'before', 'comma', '(a , b)\n   ^'))):
         self.checker.process_tokens(tokenize_str('(a , b)\n'))
开发者ID:DonJayamanne,项目名称:pylint,代码行数:5,代码来源:unittest_checker_format.py


示例19: test_skip_words_with_numbers

 def test_skip_words_with_numbers(self):
     self.checker.process_tokens(tokenize_str('\n# 0ne\n# Thr33\n# Sh3ll'))
     assert self.linter.release_messages() == []
开发者ID:pennyarcade,项目名称:py_pov,代码行数:3,代码来源:unittest_checker_spelling.py


示例20: test_skip_urls

 def test_skip_urls(self):
     self.checker.process_tokens(tokenize_str('# https://github.com/rfk/pyenchant'))
     assert self.linter.release_messages() == []
开发者ID:pennyarcade,项目名称:py_pov,代码行数:3,代码来源:unittest_checker_spelling.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.MSG_TYPES类代码示例发布时间:2022-05-25
下一篇:
Python testutils._tokenize_str函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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