summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2020-03-23 19:35:54 +0000
committerAnthony Sottile <asottile@umich.edu>2020-03-23 19:35:54 +0000
commitec4b0f6e0baa520522a3018d7cca52eeacad3be8 (patch)
tree7cdc077296676de62528103e547c39040618225c
parentd097d5103d7dcd64c672ce011acd70d3478d9588 (diff)
parent93a17a806dc88391411d7818a805adce6a321cc1 (diff)
downloadflake8-ec4b0f6e0baa520522a3018d7cca52eeacad3be8.tar.gz
Merge branch 'tests_coverage' into 'master'
instrument coverage on tests and require 100% coverage there See merge request pycqa/flake8!414
-rw-r--r--.coveragerc1
-rw-r--r--tests/integration/subdir/aplugin.py2
-rw-r--r--tests/integration/test_plugins.py4
-rw-r--r--tests/unit/test_checker_manager.py4
-rw-r--r--tests/unit/test_file_processor.py3
-rw-r--r--tests/unit/test_legacy_api.py2
-rw-r--r--tests/unit/test_style_guide.py10
-rw-r--r--tests/unit/test_utils.py4
-rw-r--r--tox.ini2
9 files changed, 16 insertions, 16 deletions
diff --git a/.coveragerc b/.coveragerc
index df0a929..7d2dd68 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -3,6 +3,7 @@ parallel = True
branch = True
source =
flake8
+ tests
omit =
# Don't complain if non-runnable code isn't run
*/__main__.py
diff --git a/tests/integration/subdir/aplugin.py b/tests/integration/subdir/aplugin.py
index 98a0464..bc5f812 100644
--- a/tests/integration/subdir/aplugin.py
+++ b/tests/integration/subdir/aplugin.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
diff --git a/tests/integration/test_plugins.py b/tests/integration/test_plugins.py
index e59eb91..859fb69 100644
--- a/tests/integration/test_plugins.py
+++ b/tests/integration/test_plugins.py
@@ -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():
diff --git a/tests/unit/test_checker_manager.py b/tests/unit/test_checker_manager.py
index 28087fe..1d7e547 100644
--- a/tests/unit/test_checker_manager.py
+++ b/tests/unit/test_checker_manager.py
@@ -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
diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py
index 044d11b..af7717e 100644
--- a/tests/unit/test_file_processor.py
+++ b/tests/unit/test_file_processor.py
@@ -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):
diff --git a/tests/unit/test_legacy_api.py b/tests/unit/test_legacy_api.py
index 886355f..0a3f884 100644
--- a/tests/unit/test_legacy_api.py
+++ b/tests/unit/test_legacy_api.py
@@ -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)
diff --git a/tests/unit/test_style_guide.py b/tests/unit/test_style_guide.py
index 38121c1..5503d7e 100644
--- a/tests/unit/test_style_guide.py
+++ b/tests/unit/test_style_guide.py
@@ -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', [
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index 151a76d..803d643 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -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
diff --git a/tox.ini b/tox.ini
index e44de43..066b77a 100644
--- a/tox.ini
+++ b/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 =