mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 15:44:17 +00:00
Add unit test for dd411e95
This commit is contained in:
parent
dd411e95bc
commit
29d8b11209
2 changed files with 21 additions and 13 deletions
|
|
@ -11,6 +11,7 @@ def options_from(**kwargs):
|
||||||
kwargs.setdefault('max_doc_length', None)
|
kwargs.setdefault('max_doc_length', None)
|
||||||
kwargs.setdefault('verbose', False)
|
kwargs.setdefault('verbose', False)
|
||||||
kwargs.setdefault('stdin_display_name', 'stdin')
|
kwargs.setdefault('stdin_display_name', 'stdin')
|
||||||
|
kwargs.setdefault('disable_noqa', False)
|
||||||
return argparse.Namespace(**kwargs)
|
return argparse.Namespace(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,21 +57,28 @@ def test_strip_utf_bom(first_line, default_options):
|
||||||
assert file_processor.lines[0] == '"""Module docstring."""\n'
|
assert file_processor.lines[0] == '"""Module docstring."""\n'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('lines, expected', [
|
@pytest.mark.parametrize('lines, expected, disable_noqa', [
|
||||||
(['\xEF\xBB\xBF"""Module docstring."""\n'], False),
|
(['\xEF\xBB\xBF"""Module docstring."""\n'], False, False),
|
||||||
([u'\uFEFF"""Module docstring."""\n'], False),
|
([u'\uFEFF"""Module docstring."""\n'], False, False),
|
||||||
(['#!/usr/bin/python', '# flake8 is great', 'a = 1'], False),
|
(['#!/usr/bin/python', '# flake8 is great', 'a = 1'], False, False),
|
||||||
(['#!/usr/bin/python', '# flake8: noqa', 'a = 1'], True),
|
(['#!/usr/bin/python', '# flake8: noqa', 'a = 1'], True, False),
|
||||||
(['#!/usr/bin/python', '# flake8:noqa', 'a = 1'], True),
|
(['#!/usr/bin/python', '# flake8: noqa', 'a = 1'], False, True),
|
||||||
(['# flake8: noqa', '#!/usr/bin/python', 'a = 1'], True),
|
(['#!/usr/bin/python', '# flake8:noqa', 'a = 1'], True, False),
|
||||||
(['# flake8:noqa', '#!/usr/bin/python', 'a = 1'], True),
|
(['#!/usr/bin/python', '# flake8:noqa', 'a = 1'], False, True),
|
||||||
(['#!/usr/bin/python', 'a = 1', '# flake8: noqa'], True),
|
(['# flake8: noqa', '#!/usr/bin/python', 'a = 1'], True, False),
|
||||||
(['#!/usr/bin/python', 'a = 1', '# flake8:noqa'], True),
|
(['# flake8: noqa', '#!/usr/bin/python', 'a = 1'], False, True),
|
||||||
(['#!/usr/bin/python', 'a = 1 # flake8: noqa'], False),
|
(['# flake8:noqa', '#!/usr/bin/python', 'a = 1'], True, False),
|
||||||
(['#!/usr/bin/python', 'a = 1 # flake8:noqa'], False),
|
(['# flake8:noqa', '#!/usr/bin/python', 'a = 1'], False, True),
|
||||||
|
(['#!/usr/bin/python', 'a = 1', '# flake8: noqa'], True, False),
|
||||||
|
(['#!/usr/bin/python', 'a = 1', '# flake8: noqa'], False, True),
|
||||||
|
(['#!/usr/bin/python', 'a = 1', '# flake8:noqa'], True, False),
|
||||||
|
(['#!/usr/bin/python', 'a = 1', '# flake8:noqa'], False, True),
|
||||||
|
(['#!/usr/bin/python', 'a = 1 # flake8: noqa'], False, False),
|
||||||
|
(['#!/usr/bin/python', 'a = 1 # flake8:noqa'], False, False),
|
||||||
])
|
])
|
||||||
def test_should_ignore_file(lines, expected, default_options):
|
def test_should_ignore_file(lines, expected, disable_noqa, default_options):
|
||||||
"""Verify that we ignore a file if told to."""
|
"""Verify that we ignore a file if told to."""
|
||||||
|
default_options.disable_noqa = disable_noqa
|
||||||
file_processor = processor.FileProcessor('-', default_options, lines)
|
file_processor = processor.FileProcessor('-', default_options, lines)
|
||||||
assert file_processor.should_ignore_file() is expected
|
assert file_processor.should_ignore_file() is expected
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue