mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46: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
ec4b0f6e0b
9 changed files with 16 additions and 16 deletions
|
|
@ -3,6 +3,7 @@ parallel = True
|
|||
branch = True
|
||||
source =
|
||||
flake8
|
||||
tests
|
||||
omit =
|
||||
# Don't complain if non-runnable code isn't run
|
||||
*/__main__.py
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ class ExtensionTestPlugin2(object):
|
|||
|
||||
def __init__(self, tree):
|
||||
"""Construct an instance of test plugin."""
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
"""Do nothing."""
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ class ExtensionTestPlugin(object):
|
|||
|
||||
def __init__(self, tree):
|
||||
"""Construct an instance of test plugin."""
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
"""Do nothing."""
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def add_options(cls, parser):
|
||||
|
|
@ -34,11 +32,9 @@ class ReportTestPlugin(object):
|
|||
|
||||
def __init__(self, tree):
|
||||
"""Construct an instance of test plugin."""
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
"""Do nothing."""
|
||||
pass
|
||||
|
||||
|
||||
def test_enable_local_plugin_from_config():
|
||||
|
|
|
|||
|
|
@ -73,5 +73,7 @@ def test_make_checkers():
|
|||
with mock.patch('flake8.processor.FileProcessor'):
|
||||
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 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)
|
||||
lines = file_processor.lines
|
||||
assert len(lines) > 5
|
||||
assert any('"""Tests for the FileProcessor class."""' in line.rstrip()
|
||||
for line in lines)
|
||||
assert lines[0].strip() == '"""Tests for the FileProcessor class."""'
|
||||
|
||||
|
||||
def _lines_from_file(tmpdir, contents, options):
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ def test_styleguide_init_report():
|
|||
|
||||
class FakeFormatter(formatter.BaseFormatter):
|
||||
def format(self, *args):
|
||||
pass
|
||||
raise NotImplementedError
|
||||
|
||||
style_guide.init_report(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)
|
||||
guide = style_guide.StyleGuideManager(options, formatter=formatter)
|
||||
assert len(guide.style_guides) == 5
|
||||
assert list(map(utils.normalize_path,
|
||||
["first_file.py", "second_file.py", "third_file.py",
|
||||
"sub_dir/*"])
|
||||
) == [g.filename for g in guide.style_guides[1:]]
|
||||
expected = [
|
||||
utils.normalize_path(p) for p in [
|
||||
"first_file.py", "second_file.py", "third_file.py", "sub_dir/*",
|
||||
]
|
||||
]
|
||||
assert expected == [g.filename for g in guide.style_guides[1:]]
|
||||
|
||||
|
||||
@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."""
|
||||
class FakeCheck(object):
|
||||
def __init__(self, tree):
|
||||
pass
|
||||
raise NotImplementedError
|
||||
|
||||
plugin = plugin_manager.Plugin('plugin-name', object())
|
||||
plugin._plugin = FakeCheck
|
||||
|
|
@ -251,7 +251,7 @@ def test_parameters_for_class_plugin():
|
|||
def test_parameters_for_function_plugin():
|
||||
"""Verify that we retrieve the parameters for a function plugin."""
|
||||
def fake_plugin(physical_line, self, tree, optional=None):
|
||||
pass
|
||||
raise NotImplementedError
|
||||
|
||||
plugin = plugin_manager.Plugin('plugin-name', object())
|
||||
plugin._plugin = fake_plugin
|
||||
|
|
|
|||
2
tox.ini
2
tox.ini
|
|
@ -11,6 +11,8 @@ commands =
|
|||
coverage run -m pytest {posargs}
|
||||
coverage combine
|
||||
coverage report
|
||||
# ensure 100% coverage of tests
|
||||
coverage report --fail-under 100 --include tests/*
|
||||
|
||||
[testenv:venv]
|
||||
deps =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue