Skip to content

Commit

Permalink
Fix checkqa: isort/flake8 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored Sep 11, 2021
2 parents bee3c1b + d99101b commit 02bea1d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default_section = THIRDPARTY
force_sort_within_sections = 1
include_trailing_comma = 1
known_first_party = covimerage
lines = 79
line_length = 79
multi_line_output = 5
order_by_type = 1
use_parentheses = 1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run(self):

DEPS_QA = [
'flake8>=3.7.0',
'flake8-isort',
'isort',
]
DEPS_TESTING = [
'pytest>=3.3.0',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,14 @@ def test_report_source(runner, tmpdir, devnull):
tmpdir.join("foo/bar/test2.vim").ensure().write("echom 2")
result = runner.invoke(cli.main, ["report", "--source", ".", devnull.name])
out = result.output.splitlines()
assert any(l.startswith(fname) for l in out) # pragma: no branch
assert any(ln.startswith(fname) for ln in out) # pragma: no branch
assert out[-1].startswith("TOTAL")
assert out[-1].endswith(" 0%")
assert result.exit_code == 0

result = runner.invoke(cli.main, ["report", devnull.name, "--source", "."])
out = result.output.splitlines()
assert any(fname in l for l in out) # pragma: no branch
assert any(fname in ln for ln in out) # pragma: no branch
assert out[-1].startswith("TOTAL")
assert out[-1].endswith(" 0%")
assert result.exit_code == 0
Expand Down
9 changes: 7 additions & 2 deletions tests/test_coveragepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def coverage_fileobj():

def test_coveragedata(coverage_fileobj):
import coverage

from covimerage.coveragepy import (
CoverageData, CoveragePyData, CoverageWrapperException)
CoverageData, CoveragePyData, CoverageWrapperException,
)

with pytest.raises(TypeError) as excinfo:
CoverageData(data_file='foo', cov_data=CoveragePyData())
Expand Down Expand Up @@ -130,8 +132,11 @@ def test_coveragedata_empty(covdata_empty):

def test_coveragewrapper(coverage_fileobj, devnull):
import coverage

from covimerage.coveragepy import (
CoverageData, CoveragePyData, CoverageWrapper, CoverageWrapperException)
CoverageData, CoveragePyData, CoverageWrapper,
CoverageWrapperException,
)

cov_data = CoverageWrapper()
assert cov_data.lines == {}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_logging_error_causes_exception(capfd):
out, err = capfd.readouterr()

lines = err.splitlines()
assert any((l.startswith('Traceback') for l in lines)) # pragma: no branch
assert any((ln.startswith('Traceback') for ln in lines)) # pragma: no branch

if not lines[-1].startswith('Logged from file test_logging.py, line '):
assert lines[-2:] == [
Expand Down
40 changes: 20 additions & 20 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_profile_parse_dict_function():
assert s.mapped_dict_functions == {3}

assert len(s.lines) == 13
assert [l.line for l in s.lines.values()] == [
assert [ln.line for ln in s.lines.values()] == [
'" Test parsing of dict function.',
'let obj = {}',
'function! obj.dict_function(arg) abort',
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_profile_parse_dict_function_with_same_source(caplog):
assert s.mapped_dict_functions == {3, 12}

N = None
assert [(l.count, l.line) for l in s.lines.values()] == [
assert [(ln.count, ln.line) for ln in s.lines.values()] == [
(N, '" Test parsing of dict function (with same source).'),
(1, 'let obj1 = {}'),
(1, 'function! obj1.dict_function(arg) abort'),
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_profile_parse_dict_function_with_continued_lines():
assert s.mapped_dict_functions == {3}

N = None
assert [(l.count, l.line) for l in s.lines.values()] == [
assert [(ln.count, ln.line) for ln in s.lines.values()] == [
(N, '" Test parsing of dict function with continued lines.'),
(1, 'let obj = {}'),
(1, 'function! obj.dict_function(arg) abort'),
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_profile_continued_lines():
assert len(p.scripts) == 1
s = p.scripts[0]

assert [(l.count, l.line) for l in s.lines.values()] == [
assert [(ln.count, ln.line) for ln in s.lines.values()] == [
(1, 'echom 1'),
(1, 'echom 2'),
(1, ' \\ 3'),
Expand All @@ -290,7 +290,7 @@ def test_conditional_functions():
s = p.scripts[0]

N = None
assert [(l.count, l.line) for l in s.lines.values()] == [
assert [(ln.count, ln.line) for ln in s.lines.values()] == [
(N, '" Test for detection of conditional functions.'),
(N, ''),
(1, 'if 0'),
Expand Down Expand Up @@ -332,7 +332,7 @@ def test_merged_profiles():

N = None
s_fname = '/test_plugin/merged_profiles.vim'
assert [(l.count, l.line) for lnum, l in m.lines[s_fname].items()] == [
assert [(ln.count, ln.line) for lnum, ln in m.lines[s_fname].items()] == [
(N, '" Generate profile output for merged profiles.'),
(N, '" Used merged_profiles-init.vim'),
(2, "if !exists('s:conditional')"),
Expand Down Expand Up @@ -374,13 +374,13 @@ def test_mergedprofiles_fixes_line_count():

script = p.scripts[0]

assert [(l.count, l.line) for l in script.lines.values()] == [
assert [(ln.count, ln.line) for ln in script.lines.values()] == [
(None, 'let foo = 1'),
(1, 'let bar = 2'),
]

m = MergedProfiles([p])
assert [(l.count, l.line) for l in m.lines[script.path].values()] == [
assert [(ln.count, ln.line) for ln in m.lines[script.path].values()] == [
(1, 'let foo = 1'),
(1, 'let bar = 2'),
]
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_function_in_function():
assert len(p.scripts) == 1
s = p.scripts[0]

assert [(l.count, l.line) for l in s.lines.values()] == [
assert [(ln.count, ln.line) for ln in s.lines.values()] == [
(None, '" Test for dict function in function.'),
(None, ''),
(1, 'function! GetObj()'),
Expand All @@ -477,7 +477,7 @@ def test_function_in_function_count(caplog):
assert len(p.scripts) == 1
s = p.scripts[0]

assert [(l.count, l.line) for l in s.lines.values()] == [
assert [(ln.count, ln.line) for ln in s.lines.values()] == [
(None, '" Test for line count with inner functions.'),
(1, 'function! Outer()'),
(None, ' " comment1'),
Expand All @@ -499,8 +499,8 @@ def test_function_in_function_with_ref(caplog):
assert len(p.scripts) == 1
s = p.scripts[0]

assert [(l.count, l.line) for l in s.lines.values()
if not l.line.startswith('"')] == [
assert [(ln.count, ln.line) for ln in s.lines.values()
if not ln.line.startswith('"')] == [
(None, ''),
(1, 'let g:refs = []'),
(None, ''),
Expand Down Expand Up @@ -548,9 +548,9 @@ def test_duplicate_s_function(caplog):
assert len(p.scripts) == 2

N = None
assert [(l.count, l.line)
for l in p.scripts[0].lines.values()
if not l.line.startswith('"')] == [
assert [(ln.count, ln.line)
for ln in p.scripts[0].lines.values()
if not ln.line.startswith('"')] == [
(1, 'function! s:function(name) abort'),
(1, ' echom a:name'),
(N, 'endfunction'),
Expand All @@ -559,9 +559,9 @@ def test_duplicate_s_function(caplog):
(1, "call test_plugin#function#function('name')"),
]

assert [(l.count, l.line)
for l in p.scripts[1].lines.values()
if not l.line.startswith('"')] == [
assert [(ln.count, ln.line)
for ln in p.scripts[1].lines.values()
if not ln.line.startswith('"')] == [
(1, 'function! s:function(name) abort'),
(1, ' echom a:name'),
(N, 'endfunction'),
Expand Down Expand Up @@ -628,8 +628,8 @@ def test_handles_unmatched_defined(platform, defined_format, defined_lnum, caplo
assert len(p.scripts) == 1
s = p.scripts[0]

assert [(l.count, l.line) for l in s.lines.values()
if not l.line.startswith('"')] == [
assert [(ln.count, ln.line) for ln in s.lines.values()
if not ln.line.startswith('"')] == [
(1, 'execute "function! F_via_execute_1()\\nreturn 0\\nendfunction"'),
(1, 'call F_via_execute_1()'),
(1, 'call F_via_execute_1()'),
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ deps =

[testenv:checkqa]
extras = qa
ignore_errors = true
commands =
flake8 --version
flake8 --show-source --statistics {posargs:covimerage tests}
isort --check --diff {posargs:covimerage tests}

0 comments on commit 02bea1d

Please sign in to comment.