mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
Merge branch 'tests_coverage' into 'master'
instrument coverage on tests and require 100% coverage there See merge request pycqa/flake8!414
This commit is contained in:
commit
7e733f50bc
9 changed files with 16 additions and 16 deletions
|
|
@ -3,6 +3,7 @@ parallel = True
|
||||||
branch = True
|
branch = True
|
||||||
source =
|
source =
|
||||||
flake8
|
flake8
|
||||||
|
tests
|
||||||
omit =
|
omit =
|
||||||
# Don't complain if non-runnable code isn't run
|
# Don't complain if non-runnable code isn't run
|
||||||
*/__main__.py
|
*/__main__.py
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ class ExtensionTestPlugin2(object):
|
||||||
|
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
"""Construct an instance of test plugin."""
|
"""Construct an instance of test plugin."""
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Do nothing."""
|
"""Do nothing."""
|
||||||
pass
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,9 @@ class ExtensionTestPlugin(object):
|
||||||
|
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
"""Construct an instance of test plugin."""
|
"""Construct an instance of test plugin."""
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Do nothing."""
|
"""Do nothing."""
|
||||||
pass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_options(cls, parser):
|
def add_options(cls, parser):
|
||||||
|
|
@ -34,11 +32,9 @@ class ReportTestPlugin(object):
|
||||||
|
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
"""Construct an instance of test plugin."""
|
"""Construct an instance of test plugin."""
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Do nothing."""
|
"""Do nothing."""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def test_enable_local_plugin_from_config():
|
def test_enable_local_plugin_from_config():
|
||||||
|
|
|
||||||
|
|
@ -73,5 +73,7 @@ def test_make_checkers():
|
||||||
with mock.patch('flake8.processor.FileProcessor'):
|
with mock.patch('flake8.processor.FileProcessor'):
|
||||||
manager.make_checkers()
|
manager.make_checkers()
|
||||||
|
|
||||||
for file_checker in manager.checkers:
|
assert manager._all_checkers
|
||||||
|
for file_checker in manager._all_checkers:
|
||||||
assert file_checker.filename in files
|
assert file_checker.filename in files
|
||||||
|
assert not manager.checkers # the files don't exist
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ def test_read_lines_splits_lines(default_options):
|
||||||
file_processor = processor.FileProcessor(__file__, default_options)
|
file_processor = processor.FileProcessor(__file__, default_options)
|
||||||
lines = file_processor.lines
|
lines = file_processor.lines
|
||||||
assert len(lines) > 5
|
assert len(lines) > 5
|
||||||
assert any('"""Tests for the FileProcessor class."""' in line.rstrip()
|
assert lines[0].strip() == '"""Tests for the FileProcessor class."""'
|
||||||
for line in lines)
|
|
||||||
|
|
||||||
|
|
||||||
def _lines_from_file(tmpdir, contents, options):
|
def _lines_from_file(tmpdir, contents, options):
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ def test_styleguide_init_report():
|
||||||
|
|
||||||
class FakeFormatter(formatter.BaseFormatter):
|
class FakeFormatter(formatter.BaseFormatter):
|
||||||
def format(self, *args):
|
def format(self, *args):
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
style_guide.init_report(FakeFormatter)
|
style_guide.init_report(FakeFormatter)
|
||||||
app.make_formatter.assert_called_once_with(FakeFormatter)
|
app.make_formatter.assert_called_once_with(FakeFormatter)
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,12 @@ def test_style_guide_manager_pre_file_ignores_parsing():
|
||||||
options = create_options(per_file_ignores=PER_FILE_IGNORES_UNPARSED)
|
options = create_options(per_file_ignores=PER_FILE_IGNORES_UNPARSED)
|
||||||
guide = style_guide.StyleGuideManager(options, formatter=formatter)
|
guide = style_guide.StyleGuideManager(options, formatter=formatter)
|
||||||
assert len(guide.style_guides) == 5
|
assert len(guide.style_guides) == 5
|
||||||
assert list(map(utils.normalize_path,
|
expected = [
|
||||||
["first_file.py", "second_file.py", "third_file.py",
|
utils.normalize_path(p) for p in [
|
||||||
"sub_dir/*"])
|
"first_file.py", "second_file.py", "third_file.py", "sub_dir/*",
|
||||||
) == [g.filename for g in guide.style_guides[1:]]
|
]
|
||||||
|
]
|
||||||
|
assert expected == [g.filename for g in guide.style_guides[1:]]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('ignores,violation,filename,handle_error_return', [
|
@pytest.mark.parametrize('ignores,violation,filename,handle_error_return', [
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ def test_parameters_for_class_plugin():
|
||||||
"""Verify that we can retrieve the parameters for a class plugin."""
|
"""Verify that we can retrieve the parameters for a class plugin."""
|
||||||
class FakeCheck(object):
|
class FakeCheck(object):
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
plugin = plugin_manager.Plugin('plugin-name', object())
|
plugin = plugin_manager.Plugin('plugin-name', object())
|
||||||
plugin._plugin = FakeCheck
|
plugin._plugin = FakeCheck
|
||||||
|
|
@ -251,7 +251,7 @@ def test_parameters_for_class_plugin():
|
||||||
def test_parameters_for_function_plugin():
|
def test_parameters_for_function_plugin():
|
||||||
"""Verify that we retrieve the parameters for a function plugin."""
|
"""Verify that we retrieve the parameters for a function plugin."""
|
||||||
def fake_plugin(physical_line, self, tree, optional=None):
|
def fake_plugin(physical_line, self, tree, optional=None):
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
plugin = plugin_manager.Plugin('plugin-name', object())
|
plugin = plugin_manager.Plugin('plugin-name', object())
|
||||||
plugin._plugin = fake_plugin
|
plugin._plugin = fake_plugin
|
||||||
|
|
|
||||||
2
tox.ini
2
tox.ini
|
|
@ -11,6 +11,8 @@ commands =
|
||||||
coverage run -m pytest {posargs}
|
coverage run -m pytest {posargs}
|
||||||
coverage combine
|
coverage combine
|
||||||
coverage report
|
coverage report
|
||||||
|
# ensure 100% coverage of tests
|
||||||
|
coverage report --fail-under 100 --include tests/*
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
deps =
|
deps =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue