diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index f47acfa..bb4b90c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -30,7 +30,7 @@ jobs: if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi - name: Lint with flake8, black, isort, pydocstyle run: | - flake8 bashplot/ --count --max-line-length=88 --ignore=W293,W291 --statistic + flake8 bashplot/ --count --statistic black . --check -v isort . --check -v flake8 . --count --exit-zero --max-complexity=10 --statistics @@ -40,7 +40,7 @@ jobs: pip install . - name: Test with pytest and coverage run: | - coverage run -m pytest test/test*.py -vv + coverage run -m pytest -vv coverage report -m coverage xml - name: Codecov diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ebd7fc6..22031a1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,7 +32,7 @@ steps: displayName: 'Install dependencies' - script: | - flake8 bashplot/ --count --max-line-length=88 --ignore=W293,W291 --statistic + flake8 bashplot/ --count --statistic black . --check -v isort . --check -v flake8 . --count --exit-zero --max-complexity=10 --statistics @@ -44,7 +44,7 @@ steps: displayName: 'Install bashplot' - script: | - coverage run -m pytest test/test*.py -vv + coverage run -m pytest -vv coverage report -m coverage xml displayName: 'pytest' diff --git a/bashplot/bashplot.py b/bashplot/bashplot.py index 388dcc5..b84b638 100644 --- a/bashplot/bashplot.py +++ b/bashplot/bashplot.py @@ -95,7 +95,7 @@ def plot_plot(fig, x, Y, label): def plot_scatter(fig, x, Y, label): """Make the scatter-figures. - plot_scatter() is generating a single- or multi-plot by recursiving calling + plot_scatter() is generating a single- or multi-plot by recursive calling scatter(). Parameters diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..20fc96a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,17 @@ +[flake8] +max-line-length = 88 +extend-ignore = E203, W503, W293, W291 + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +ensure_newline_before_comments = true +line_length = 88 + +[pylint] +max-line-length = 88 + +[pylint.messages_control] +disable = C0330, C0326 \ No newline at end of file diff --git a/test/test_bashplot.py b/test/test_bashplot.py index d73dcf9..bf4f582 100644 --- a/test/test_bashplot.py +++ b/test/test_bashplot.py @@ -3,6 +3,7 @@ from pathlib import Path from unittest import mock +import pytest import sample_generator from bashplot import bashplot @@ -11,8 +12,8 @@ print() -test_txt = Path.cwd().glob("test*.txt") -test_dat = Path.cwd().glob("test*.dat") +test_txt = list(Path.cwd().glob("test*.txt")) +test_dat = list(Path.cwd().glob("test*.dat")) args_1 = { "infile": test_txt, @@ -103,24 +104,56 @@ def test_usecols(): @mock.patch("bashplot.bashplot.bashplot") -def test_default_run(bashplot): +def test_default_run_mock(bashplot): bashplot.bashplot(fnames=test_txt, args=args_1) assert bashplot.bashplot.is_called +def test_default_run(): + bashplot.bashplot(fnames=test_txt, args=args_1) + assert True + + @mock.patch("bashplot.bashplot.bashplot") -def test_customize_run_1(bashplot): +def test_customize_run_mock_1(bashplot): bashplot.bashplot(fnames=test_txt, args=args_2) assert bashplot.bashplot.is_called +def test_customize_run_1(): + bashplot.bashplot(fnames=test_txt, args=args_2) + assert True + + @mock.patch("bashplot.bashplot.bashplot") -def test_customize_run_2(bashplot): +def test_customize_run_mock_2(bashplot): bashplot.bashplot(fnames=test_dat, args=args_3) assert bashplot.bashplot.is_called +def test_customize_run_2(): + bashplot.bashplot(fnames=test_dat, args=args_3) + assert True + + @mock.patch("bashplot.bashplot.command_line_runner") -def test_command_line(command_line_runner): +def test_command_line_mock(command_line_runner): bashplot.command_line_runner() assert bashplot.command_line_runner.is_called + + +def test_command_line_1(): + bashplot.command_line_runner() + assert True + + +def test_log(capfd): + bashplot.log("msg") + out, _ = capfd.readouterr() + assert out == "msg\n" + + +def test_log_error(capfd): + bashplot.log("msg", mode=True) + out, _ = capfd.readouterr() + assert out == "[ERROR] msg\n"