本文整理匯總了Python中flake8_quotes.QuoteChecker.get_file_contents方法的典型用法代碼示例。如果您正苦於以下問題:Python QuoteChecker.get_file_contents方法的具體用法?Python QuoteChecker.get_file_contents怎麽用?Python QuoteChecker.get_file_contents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flake8_quotes.QuoteChecker
的用法示例。
在下文中一共展示了QuoteChecker.get_file_contents方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_require_double_docstring_double_present
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [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'},
])
示例2: test_doubles
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_doubles(self):
doubles_checker = QuoteChecker(None, filename=get_absolute_path('data/doubles_wrapped.py'))
self.assertEqual(list(doubles_checker.get_quotes_errors(doubles_checker.get_file_contents())), [])
doubles_checker = QuoteChecker(None, filename=get_absolute_path('data/doubles.py'))
self.assertEqual(list(doubles_checker.get_quotes_errors(doubles_checker.get_file_contents())), [
{'col': 24, 'line': 1, 'message': 'Q000 Remove bad quotes'},
{'col': 24, 'line': 2, 'message': 'Q000 Remove bad quotes'},
{'col': 24, 'line': 3, 'message': 'Q000 Remove bad quotes'},
])
示例3: test_escapes_allowed
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [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())), [])
示例4: test_doubles_alias
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [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'},
])
示例5: test_get_noqa_lines
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_get_noqa_lines(self):
checker = QuoteChecker(None, filename=get_absolute_path('data/no_qa.py'))
self.assertEqual(checker.get_noqa_lines(checker.get_file_contents()), [2])
示例6: test_singles
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_singles(self):
singles_checker = QuoteChecker(None, filename=get_absolute_path('data/singles.py'))
self.assertEqual(list(singles_checker.get_quotes_errors(singles_checker.get_file_contents())), [
{'col': 24, 'line': 1, 'message': 'Q000 Remove bad quotes.'}
])
示例7: test_wrapped
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_wrapped(self):
singles_checker = QuoteChecker(None, filename=get_absolute_path('data/singles_wrapped.py'))
self.assertEqual(list(singles_checker.get_quotes_errors(singles_checker.get_file_contents())), [])
示例8: test_multiline_string
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_multiline_string(self):
doubles_checker = QuoteChecker(None, filename=get_absolute_path('data/doubles_multiline_string.py'))
self.assertEqual(list(doubles_checker.get_quotes_errors(doubles_checker.get_file_contents())), [])
示例9: test_escapes
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_escapes(self):
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())), [
{'col': 25, 'line': 1, 'message': 'Q003 Change outer quotes to avoid escaping inner quotes'},
])
示例10: test_multiline_string
# 需要導入模塊: from flake8_quotes import QuoteChecker [as 別名]
# 或者: from flake8_quotes.QuoteChecker import get_file_contents [as 別名]
def test_multiline_string(self):
doubles_checker = QuoteChecker(None, filename=get_absolute_path('data/doubles_multiline_string.py'))
self.assertEqual(list(doubles_checker.get_quotes_errors(doubles_checker.get_file_contents())), [
{'col': 4, 'line': 1, 'message': 'Q001 Remove bad quotes from multiline string'},
])