Skip to content

Commit cc0c6db

Browse files
authored
Merge pull request #19 from Anselmoo/coverage
Update test
2 parents d8a747b + e0f5325 commit cc0c6db

File tree

5 files changed

+61
-11
lines changed

5 files changed

+61
-11
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
3131
- name: Lint with flake8, black, isort, pydocstyle
3232
run: |
33-
flake8 bashplot/ --count --max-line-length=88 --ignore=W293,W291 --statistic
33+
flake8 bashplot/ --count --statistic
3434
black . --check -v
3535
isort . --check -v
3636
flake8 . --count --exit-zero --max-complexity=10 --statistics
@@ -40,7 +40,7 @@ jobs:
4040
pip install .
4141
- name: Test with pytest and coverage
4242
run: |
43-
coverage run -m pytest test/test*.py -vv
43+
coverage run -m pytest -vv
4444
coverage report -m
4545
coverage xml
4646
- name: Codecov

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ steps:
3232
displayName: 'Install dependencies'
3333

3434
- script: |
35-
flake8 bashplot/ --count --max-line-length=88 --ignore=W293,W291 --statistic
35+
flake8 bashplot/ --count --statistic
3636
black . --check -v
3737
isort . --check -v
3838
flake8 . --count --exit-zero --max-complexity=10 --statistics
@@ -44,7 +44,7 @@ steps:
4444
displayName: 'Install bashplot'
4545

4646
- script: |
47-
coverage run -m pytest test/test*.py -vv
47+
coverage run -m pytest -vv
4848
coverage report -m
4949
coverage xml
5050
displayName: 'pytest'

bashplot/bashplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def plot_plot(fig, x, Y, label):
9595
def plot_scatter(fig, x, Y, label):
9696
"""Make the scatter-figures.
9797
98-
plot_scatter() is generating a single- or multi-plot by recursiving calling
98+
plot_scatter() is generating a single- or multi-plot by recursive calling
9999
scatter().
100100
101101
Parameters

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, W503, W293, W291
4+
5+
[tool.isort]
6+
multi_line_output = 3
7+
include_trailing_comma = true
8+
force_grid_wrap = 0
9+
use_parentheses = true
10+
ensure_newline_before_comments = true
11+
line_length = 88
12+
13+
[pylint]
14+
max-line-length = 88
15+
16+
[pylint.messages_control]
17+
disable = C0330, C0326

test/test_bashplot.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44
from unittest import mock
55

6+
import pytest
67
import sample_generator
78

89
from bashplot import bashplot
@@ -11,8 +12,8 @@
1112

1213
print()
1314

14-
test_txt = Path.cwd().glob("test*.txt")
15-
test_dat = Path.cwd().glob("test*.dat")
15+
test_txt = list(Path.cwd().glob("test*.txt"))
16+
test_dat = list(Path.cwd().glob("test*.dat"))
1617

1718
args_1 = {
1819
"infile": test_txt,
@@ -103,24 +104,56 @@ def test_usecols():
103104

104105

105106
@mock.patch("bashplot.bashplot.bashplot")
106-
def test_default_run(bashplot):
107+
def test_default_run_mock(bashplot):
107108
bashplot.bashplot(fnames=test_txt, args=args_1)
108109
assert bashplot.bashplot.is_called
109110

110111

112+
def test_default_run():
113+
bashplot.bashplot(fnames=test_txt, args=args_1)
114+
assert True
115+
116+
111117
@mock.patch("bashplot.bashplot.bashplot")
112-
def test_customize_run_1(bashplot):
118+
def test_customize_run_mock_1(bashplot):
113119
bashplot.bashplot(fnames=test_txt, args=args_2)
114120
assert bashplot.bashplot.is_called
115121

116122

123+
def test_customize_run_1():
124+
bashplot.bashplot(fnames=test_txt, args=args_2)
125+
assert True
126+
127+
117128
@mock.patch("bashplot.bashplot.bashplot")
118-
def test_customize_run_2(bashplot):
129+
def test_customize_run_mock_2(bashplot):
119130
bashplot.bashplot(fnames=test_dat, args=args_3)
120131
assert bashplot.bashplot.is_called
121132

122133

134+
def test_customize_run_2():
135+
bashplot.bashplot(fnames=test_dat, args=args_3)
136+
assert True
137+
138+
123139
@mock.patch("bashplot.bashplot.command_line_runner")
124-
def test_command_line(command_line_runner):
140+
def test_command_line_mock(command_line_runner):
125141
bashplot.command_line_runner()
126142
assert bashplot.command_line_runner.is_called
143+
144+
145+
def test_command_line_1():
146+
bashplot.command_line_runner()
147+
assert True
148+
149+
150+
def test_log(capfd):
151+
bashplot.log("msg")
152+
out, _ = capfd.readouterr()
153+
assert out == "msg\n"
154+
155+
156+
def test_log_error(capfd):
157+
bashplot.log("msg", mode=True)
158+
out, _ = capfd.readouterr()
159+
assert out == "[ERROR] msg\n"

0 commit comments

Comments
 (0)