|
15 | 15 | # along with pytest-workflow. If not, see <https://www.gnu.org/licenses/ |
16 | 16 |
|
17 | 17 | """core functionality of pytest-workflow plugin""" |
| 18 | +import argparse |
18 | 19 | import shutil |
19 | 20 | import tempfile |
20 | 21 | import warnings |
@@ -81,10 +82,25 @@ def pytest_addoption(parser: PytestParser): |
81 | 82 | action="append", |
82 | 83 | type=str, |
83 | 84 | # 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." |
85 | 87 | ) |
86 | 88 |
|
87 | 89 |
|
| 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 | + |
88 | 104 | def pytest_collect_file(path, parent): |
89 | 105 | """Collection hook |
90 | 106 | This collects the yaml files that start with "test" and end with |
@@ -157,8 +173,6 @@ def pytest_configure(config: PytestConfig): |
157 | 173 |
|
158 | 174 | def pytest_collection(session: pytest.Session): |
159 | 175 | """This function is started at the beginning of collection""" |
160 | | - # pylint: disable=unused-argument |
161 | | - # needed for pytest |
162 | 176 | # We print an empty line here to make the report look slightly better. |
163 | 177 | # Without it pytest will output "Collecting ... " and the workflow commands |
164 | 178 | # will be immediately after this: "Collecting ... queue (etc.) " |
@@ -410,8 +424,6 @@ def runtest(self): |
410 | 424 | assert self.workflow.exit_code == self.desired_exit_code |
411 | 425 |
|
412 | 426 | def repr_failure(self, excinfo): |
413 | | - # pylint: disable=unused-argument |
414 | | - # excinfo needed for pytest. |
415 | 427 | message = ("'{workflow_name}' exited with exit code " + |
416 | 428 | "'{exit_code}' instead of '{desired_exit_code}'." |
417 | 429 | ).format(workflow_name=self.workflow.name, |
|
0 commit comments