Skip to content

Commit 8118851

Browse files
authored
Merge pull request #89 from LUMC/release_1.2.2
Release 1.2.2
2 parents 71acdaa + 1295bf2 commit 8118851

File tree

11 files changed

+109
-26
lines changed

11 files changed

+109
-26
lines changed

.travis.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ matrix:
99
include:
1010
# TEST DOCS AND LINTING
1111
# Use default python3 version here.
12-
- env: TOX_ENV=py3-docs
13-
- env: TOX_ENV=py3-lint
12+
- env: TOX_ENV=docs
13+
- env: TOX_ENV=lint
1414

1515
# UNIT TESTS
1616
# On most recent versions of python.
1717
- python: 3.6
1818
env: TOX_ENV=py36
1919
- python: 3.7
2020
env: TOX_ENV=py37
21+
- python: 3.8
22+
env: TOX_ENV=py38
2123
- python: 3.5
2224
env: TOX_ENV=py35
2325
install:
@@ -37,11 +39,11 @@ matrix:
3739
- codecov -v # -v to make sure coverage upload works.
3840

3941
# FUNCTIONAL TESTS
40-
- python: 3.5
41-
env: TOX_ENV=py3-snakemake
4242
- python: 3.6
43-
env: TOX_ENV=py3-snakemake
44-
- env: TOX_ENV=py3-cromwell
43+
env: TOX_ENV=snakemake
44+
- python: 3.7
45+
env: TOX_ENV=snakemake
46+
- env: TOX_ENV=cromwell
4547
before_install:
4648
# Install conda
4749
- export MINICONDA=${HOME}/miniconda

HISTORY.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@ Changelog
44

55
.. Newest changes should be on top.
66
7-
.. NOTE: This document is user facing. Please word the changes in such a way
7+
.. 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.2.2
11+
---------------------------
12+
+ Test against python3.8
13+
+ Do not test on python3.5 snakemake as it crashes. Added test for python3.7
14+
snakemake.
15+
+ Fix a typo in the documentation.
16+
+ Add tags 'wdl', 'cromwell' and 'snakemake' to the package to increase
17+
discoverability.
18+
+ Remove pylint from the lint procedure as it was very strict and got stricter
19+
with every update, causing tests that previously succeeded to fail on a
20+
regular basis.
21+
+ Make sure pytest-workflow crashes when multiple workflows have the same name,
22+
even when they are in different files.
23+
+ Added setup.cfg to include license in source distributions on PyPI for
24+
future versions
25+
1026
version 1.2.1
1127
---------------------------
1228
+ Since pytest 4.5.0 unknown markers give a warning. ``@pytest.mark.workflow``

docs/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ On Ubuntu or Debian
2222
``python3 -m pip install --user pytest-workflow``
2323
- ``pytest`` can now be run with ``python3 -m pytest``.
2424

25-
.. container:: note
25+
.. note::
2626

27-
NOTE: Running plain ``pytest`` on Ubuntu or Debian outside of a virtual
27+
Running plain ``pytest`` on Ubuntu or Debian outside of a virtual
2828
environment will not work with ``pytest-workflow`` because this will start
2929
the python2 version of ``pytest``. This is because python2 is the default
3030
python on any distribution released before January 1st 2020.

docs/running_pytest_workflow.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ workflows that have succeeded.
2121
If you wish to change the temporary directory in which the workflows are run
2222
use ``--basetemp <dir>`` to change pytest's base temp directory.
2323

24-
.. container:: warning
24+
.. warning::
2525

26-
WARNING: When a directory is passed to ``--basetemp`` some of the directory
26+
When a directory is passed to ``--basetemp`` some of the directory
2727
contents will be deleted. For example: if your workflow is named
2828
``"my workflow"`` then any file or directory named ``my_workflow`` will be
2929
deleted. This makes sure you start with a clean slate if you run pytest

docs/writing_tests.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ Test options
6060
files:
6161
- path: "fail.log" # Multiple files can be tested for each workflow
6262
- path: "TomCruise.txt.gz" # Gzipped files can also be searched, provided their extension is '.gz'
63-
contains: "starring"
63+
contains:
64+
- "starring"
6465
stderr: # Options for testing stderr (optional)
6566
contains: # A list of strings which should be in stderr (optional)
6667
- "BSOD error, please contact the IT crowd"
@@ -70,6 +71,10 @@ Test options
7071
7172
The above YAML file contains all the possible options for a workflow test.
7273

74+
.. note::
75+
Workflow names must be unique. Pytest workflow will crash when multiple
76+
workflows have the same name, even if they are in different files.
77+
7378
Writing custom tests
7479
--------------------
7580

@@ -102,7 +107,7 @@ containing numbers' has run.
102107
points to the folder where the named workflow was executed. This allows writing of
103108
advanced python tests for each file produced by the workflow.
104109

105-
.. container:: note
110+
.. note::
106111

107-
NOTE: stdout and stderr are available as files in the root of the
112+
stdout and stderr are available as files in the root of the
108113
``workflow_dir`` as ``log.out`` and ``log.err`` respectively.

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
markers =
3+
functional: This marks functional tests for pytest-workflow. These are the tests for pytest-workflow that are executed using different workflow engines.

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[metadata]
2+
license_file=LICENSE
3+

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
setup(
2323
name="pytest-workflow",
24-
version="1.2.1",
24+
version="1.2.2",
2525
description="A pytest plugin for configuring workflow/pipeline tests "
2626
"using YAML files",
2727
author="Leiden University Medical Center",
2828
author_email="[email protected]", # A placeholder for now
2929
long_description=LONG_DESCRIPTION,
3030
long_description_content_type="text/x-rst",
3131
license="AGPL-3.0-or-later",
32-
keywords="pytest workflow pipeline yaml yml",
32+
keywords="pytest workflow pipeline yaml yml wdl cromwell snakemake",
3333
zip_safe=False,
3434
packages=find_packages('src'),
3535
package_dir={'': 'src'},
@@ -43,6 +43,7 @@
4343
"Programming Language :: Python :: 3.5",
4444
"Programming Language :: Python :: 3.6",
4545
"Programming Language :: Python :: 3.7",
46+
"Programming Language :: Python :: 3.8",
4647
"Development Status :: 5 - Production/Stable",
4748
"License :: OSI Approved :: "
4849
"GNU Affero General Public License v3 or later (AGPLv3+)",

src/pytest_workflow/plugin.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import tempfile
2020
import warnings
2121
from pathlib import Path
22-
from typing import List, Optional # noqa: F401 needed for typing.
22+
from typing import Dict, List, Optional # noqa: F401 needed for typing.
2323

2424
from _pytest.config import Config as PytestConfig
2525
from _pytest.config.argparsing import Parser as PytestParser
@@ -115,7 +115,7 @@ def pytest_configure(config: PytestConfig):
115115
setattr(config, "workflow_queue", workflow_queue)
116116

117117
# Save which workflows are run and which are not.
118-
executed_workflows = [] # type: List[str]
118+
executed_workflows = {} # type: Dict[str, str]
119119
setattr(config, "executed_workflows", executed_workflows)
120120

121121
# Save workflow for cleanup in this var.
@@ -191,7 +191,7 @@ def pytest_collection_modifyitems(config: PytestConfig,
191191
raise TypeError("A workflow name should be defined in the "
192192
"workflow marker of {0}".format(item.nodeid))
193193

194-
if workflow_name not in config.executed_workflows:
194+
if workflow_name not in config.executed_workflows.keys():
195195
skip_marker = pytest.mark.skip(
196196
reason="'{0}' has not run.".format(workflow_name))
197197
item.add_marker(skip_marker)
@@ -204,6 +204,26 @@ def pytest_runtestloop(session: pytest.Session):
204204
)
205205

206206

207+
def pytest_collectstart(collector: pytest.Collector):
208+
"""This runs before the collector runs its collect attribute"""
209+
210+
if isinstance(collector, WorkflowTestsCollector):
211+
name = collector.workflow_test.name # type: str
212+
213+
# Executed workflows contains workflow name as key and nodeid as value.
214+
executed_workflows = collector.config.executed_workflows # type: Dict[str,str] # noqa: E501
215+
216+
if name in executed_workflows.keys():
217+
raise ValueError(
218+
"Workflow name '{this}' used more than once. Conflicting "
219+
"tests: {this_test}, {existing_test}. ".format(
220+
this=name,
221+
this_test=collector.nodeid,
222+
existing_test=executed_workflows[name]
223+
)
224+
)
225+
226+
207227
def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
208228
# No cleanup needed if we keep workflow directories
209229
# Or if there are no directories to cleanup. (I.e. pytest-workflow plugin
@@ -340,7 +360,10 @@ def collect(self):
340360
return []
341361
else:
342362
# If we run the workflow, save this for reference later.
343-
self.config.executed_workflows.append(self.workflow_test.name)
363+
# Save the nodeid because it also contains the originating file.
364+
# This is useful for error messages later.
365+
self.config.executed_workflows[self.workflow_test.name] = (
366+
self.nodeid)
344367

345368
# This creates a workflow that is queued for processing after the
346369
# collection phase.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (C) 2018 Leiden University Medical Center
2+
# This file is part of pytest-workflow
3+
#
4+
# pytest-workflow is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as
6+
# published by the Free Software Foundation, either version 3 of the
7+
# License, or (at your option) any later version.
8+
#
9+
# pytest-workflow is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with pytest-workflow. If not, see <https://www.gnu.org/licenses/
16+
17+
from .test_success_messages import SIMPLE_ECHO
18+
19+
20+
def test_same_name_different_files(testdir):
21+
testdir.makefile(".yml", test_a=SIMPLE_ECHO)
22+
testdir.makefile(".yml", test_b=SIMPLE_ECHO)
23+
result = testdir.runpytest()
24+
assert result.ret != 0
25+
assert ("Workflow name 'simple echo' used more than once"
26+
in result.stdout.str())
27+
conflicting_message = (
28+
"Conflicting tests: {0}, {1}.".format(
29+
"test_b.yml::" + "simple echo",
30+
"test_a.yml::" + "simple echo")
31+
)
32+
assert conflicting_message in result.stdout.str()

0 commit comments

Comments
 (0)