當前位置: 首頁>>代碼示例>>Python>>正文


Python QuoteChecker.parse_options方法代碼示例

本文整理匯總了Python中flake8_quotes.QuoteChecker.parse_options方法的典型用法代碼示例。如果您正苦於以下問題:Python QuoteChecker.parse_options方法的具體用法?Python QuoteChecker.parse_options怎麽用?Python QuoteChecker.parse_options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flake8_quotes.QuoteChecker的用法示例。


在下文中一共展示了QuoteChecker.parse_options方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_escapes_allowed

# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import parse_options [as 別名]
    def test_escapes_allowed(self):
        class Options():
            inline_quotes = "'"
            avoid_escape = False
        QuoteChecker.parse_options(Options)

        doubles_checker = QuoteChecker(None, filename=get_absolute_path('data/doubles_escaped.py'))
        self.assertEqual(list(doubles_checker.get_quotes_errors(doubles_checker.get_file_contents())), [])
開發者ID:zheller,項目名稱:flake8-quotes,代碼行數:10,代碼來源:test_checks.py

示例2: test_require_double_docstring_double_present

# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import parse_options [as 別名]
    def test_require_double_docstring_double_present(self):
        class Options():
            inline_quotes = 'single'
            multiline_quotes = 'single'
            docstring_quotes = 'double'
        QuoteChecker.parse_options(Options)

        multiline_checker = QuoteChecker(
            None,
            filename=get_absolute_path('data/docstring_doubles.py')
        )
        self.assertEqual(list(multiline_checker.get_quotes_errors(multiline_checker.get_file_contents())), [
            {'col': 0, 'line': 5, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 4, 'line': 16, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 20, 'line': 21, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 8, 'line': 30, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 12, 'line': 35, 'message': 'Q001 Remove bad quotes from multiline string'},
        ])

        multiline_checker = QuoteChecker(
            None,
            filename=get_absolute_path('data/docstring_doubles_module_multiline.py')
        )
        self.assertEqual(list(multiline_checker.get_quotes_errors(multiline_checker.get_file_contents())), [
            {'col': 0, 'line': 4, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 0, 'line': 9, 'message': 'Q001 Remove bad quotes from multiline string'},
        ])

        multiline_checker = QuoteChecker(
            None,
            filename=get_absolute_path('data/docstring_doubles_module_singleline.py')
        )
        self.assertEqual(list(multiline_checker.get_quotes_errors(multiline_checker.get_file_contents())), [
            {'col': 0, 'line': 2, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 0, 'line': 6, 'message': 'Q001 Remove bad quotes from multiline string'},
        ])

        multiline_checker = QuoteChecker(
            None,
            filename=get_absolute_path('data/docstring_doubles_class.py')
        )
        self.assertEqual(list(multiline_checker.get_quotes_errors(multiline_checker.get_file_contents())), [
            {'col': 4, 'line': 3, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 22, 'line': 5, 'message': 'Q001 Remove bad quotes from multiline string'},
        ])

        multiline_checker = QuoteChecker(
            None,
            filename=get_absolute_path('data/docstring_doubles_function.py')
        )
        self.assertEqual(list(multiline_checker.get_quotes_errors(multiline_checker.get_file_contents())), [
            {'col': 4, 'line': 3, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 4, 'line': 11, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 38, 'line': 15, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 4, 'line': 17, 'message': 'Q001 Remove bad quotes from multiline string'},
            {'col': 4, 'line': 21, 'message': 'Q001 Remove bad quotes from multiline string'},
        ])
開發者ID:zheller,項目名稱:flake8-quotes,代碼行數:59,代碼來源:test_docstring_checks.py

示例3: test_doubles_alias

# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import parse_options [as 別名]
    def test_doubles_alias(self):
        class Options():
            inline_quotes = 'double'
            multiline_quotes = 'single'
        QuoteChecker.parse_options(Options)

        multiline_checker = QuoteChecker(None, filename=get_absolute_path('data/multiline_string.py'))
        self.assertEqual(list(multiline_checker.get_quotes_errors(multiline_checker.get_file_contents())), [
            {'col': 4, 'line': 1, 'message': 'Q001 Remove bad quotes from multiline string'},
        ])
開發者ID:zheller,項目名稱:flake8-quotes,代碼行數:12,代碼來源:test_checks.py

示例4: setUp

# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import parse_options [as 別名]
 def setUp(self):
     class SinglesOptions():
         inline_quotes = '"'
     QuoteChecker.parse_options(SinglesOptions)
開發者ID:jdavidheiser,項目名稱:flake8-quotes,代碼行數:6,代碼來源:test_checks.py

示例5: setUp

# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import parse_options [as 別名]
 def setUp(self):
     class DoublesAliasOptions():
         inline_quotes = 'single'
         multiline_quotes = 'single'
     QuoteChecker.parse_options(DoublesAliasOptions)
開發者ID:zheller,項目名稱:flake8-quotes,代碼行數:7,代碼來源:test_checks.py


注:本文中的flake8_quotes.QuoteChecker.parse_options方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。