Skip to content

Commit 27b3787

Browse files
authored
Merge pull request #90 from LUMC/cliimprovements
Better CLI documentation. Remove old CI tests and linting clutter.
2 parents 728cf82 + 46818ea commit 27b3787

16 files changed

+48
-57
lines changed

.pylintrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,9 @@ matrix:
2323
- python: 3.5
2424
env: TOX_ENV=py35
2525
install:
26-
- pip install codacy-coverage
2726
- pip install codecov
2827
- pip install tox
2928
after_success:
30-
# Correct coverage xml for coverage services.
31-
- >
32-
bash -c 'set -eux;
33-
pkg_path=$(find .tox/py*/lib/python*/site-packages/pytest_workflow -maxdepth 0 -type d);
34-
sed -i "s:${pkg_path}:src/pytest_workflow:g" coverage.xml'
35-
- >
36-
bash -c ' if [[ -v CODACY_PROJECT_TOKEN ]]; then
37-
python-codacy-coverage -r coverage.xml;
38-
fi'
3929
- codecov -v # -v to make sure coverage upload works.
4030

4131
# FUNCTIONAL TESTS

HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10+
version 1.3.0-dev
11+
---------------------------
12+
13+
+ Documentation: added usage chapter for pytest-workflow specific options.
14+
+ Added missing `help` for `--tag`.
15+
+ Removed redundant references to pylint in code comments and CI.
16+
+ Remove Codacy from the CI.
17+
1018
version 1.2.2
1119
---------------------------
1220
+ Test against python3.8

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@
4646
# Add any Sphinx extension module names here, as strings. They can be
4747
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4848
# ones.
49-
extensions = [
50-
]
51-
49+
extensions = ['sphinxarg.ext']
5250
# Add any paths that contain templates here, relative to this directory.
5351
templates_path = ['_templates']
5452

docs/running_pytest_workflow.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
=======================
22
Running pytest-workflow
33
=======================
4+
5+
Usage
6+
-----
7+
48
Run ``pytest`` from an environment with pytest-workflow installed or
59
``python3 -m pytest`` if using a system-wide or user-wide installation.
610
Pytest will automatically gather files in the ``tests`` directory starting with
@@ -9,6 +13,16 @@ Pytest will automatically gather files in the ``tests`` directory starting with
913
The workflows are run automatically. Each workflow gets its own temporary
1014
directory to run. The ``stdout`` and ``stderr`` of the workflow command are
1115
also saved to this directory to ``log.out`` and ``log.err`` respectively.
16+
17+
18+
.. argparse::
19+
:module: pytest_workflow.plugin
20+
:func: __pytest_workflow_cli
21+
:prog: pytest
22+
23+
Temporary directory cleanup
24+
---------------------------
25+
1226
The temporary directories are cleaned up after the tests are completed.
1327
If you wish to inspect the output of a failing
1428
workflow you can use the ``--keep-workflow-wd`` or ``--kwd`` flag to disable
@@ -31,6 +45,9 @@ use ``--basetemp <dir>`` to change pytest's base temp directory.
3145
DO NOT use ``--basetemp`` on directories where none of the
3246
contents should be deleted.
3347

48+
Running multiple workflows simultaneously
49+
-----------------------------------------
50+
3451
To run multiple workflows simultaneously you can use
3552
``--workflow-threads <int>`` or ``--wt <int>`` flag. This defines the number
3653
of workflows that can be run simultaneously. This will speed up things if

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ flake8
44
flake8-import-order
55
mypy
66
bandit
7-
pylint

requirements-docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
setuptools
22
sphinx
3+
sphinx-argparse
34
sphinx_rtd_theme

src/pytest_workflow/content_tests.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ def __init__(self, name: str, parent: pytest.Collector,
109109
:param content_name: The name of the content that will be displayed if
110110
the test fails. Defaults to filepath.
111111
"""
112-
# pylint: disable=too-many-arguments
113-
# Cannot think of a better way to do this.
114112
super().__init__(name, parent=parent)
115113
self.filepath = filepath
116114
self.content_test = content_test
@@ -205,8 +203,6 @@ def runtest(self):
205203
self.should_contain)
206204

207205
def repr_failure(self, excinfo):
208-
# pylint: disable=unused-argument
209-
# excinfo needed for pytest.
210206
if self.parent.file_not_found:
211207
return (
212208
"'{content}' does not exist and cannot be searched "

src/pytest_workflow/file_tests.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def runtest(self):
101101
assert self.file.exists() == self.should_exist
102102

103103
def repr_failure(self, excinfo):
104-
# pylint: disable=unused-argument
105-
# excinfo needed for pytest.
106104
message = "'{path}' does {exist} while it {should}".format(
107105
# self.file gives the actual path that was tested (including /tmp
108106
# bits). self.parent.filetest.path gives the path that the user
@@ -139,8 +137,6 @@ def runtest(self):
139137
assert self.observed_md5sum == self.expected_md5sum
140138

141139
def repr_failure(self, excinfo):
142-
# pylint: disable=unused-argument
143-
# excinfo needed for pytest.
144140
message = (
145141
"Observed md5sum '{observed}' not equal to expected md5sum "
146142
"'{expected}' for file '{path}'"

src/pytest_workflow/plugin.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# along with pytest-workflow. If not, see <https://www.gnu.org/licenses/
1616

1717
"""core functionality of pytest-workflow plugin"""
18+
import argparse
1819
import shutil
1920
import tempfile
2021
import warnings
@@ -81,10 +82,25 @@ def pytest_addoption(parser: PytestParser):
8182
action="append",
8283
type=str,
8384
# Otherwise default is None and this does not work with list operations
84-
default=[]
85+
default=[],
86+
help="Run workflows with this name or tag."
8587
)
8688

8789

90+
def __pytest_workflow_cli(): # pragma: no cover
91+
"""Helper function for showing all pytest-workflow specific options in the
92+
documentation with sphinx argparse. The ArgParser class bypasses any
93+
pytest specific implementation of the PytestParser to use a common
94+
argparse.ArgumentParser instead."""
95+
class ArgParser(argparse.ArgumentParser):
96+
def addoption(self, *args, **kwargs):
97+
self.add_argument(*args, **kwargs)
98+
99+
parser = ArgParser()
100+
pytest_addoption(parser)
101+
return parser
102+
103+
88104
def pytest_collect_file(path, parent):
89105
"""Collection hook
90106
This collects the yaml files that start with "test" and end with
@@ -157,8 +173,6 @@ def pytest_configure(config: PytestConfig):
157173

158174
def pytest_collection(session: pytest.Session):
159175
"""This function is started at the beginning of collection"""
160-
# pylint: disable=unused-argument
161-
# needed for pytest
162176
# We print an empty line here to make the report look slightly better.
163177
# Without it pytest will output "Collecting ... " and the workflow commands
164178
# will be immediately after this: "Collecting ... queue (etc.) "
@@ -410,8 +424,6 @@ def runtest(self):
410424
assert self.workflow.exit_code == self.desired_exit_code
411425

412426
def repr_failure(self, excinfo):
413-
# pylint: disable=unused-argument
414-
# excinfo needed for pytest.
415427
message = ("'{workflow_name}' exited with exit code " +
416428
"'{exit_code}' instead of '{desired_exit_code}'."
417429
).format(workflow_name=self.workflow.name,

0 commit comments

Comments
 (0)