-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip content tests when file does not exist. #152
Changes from 9 commits
debfbac
effe8ac
e720d5f
cf40b24
9a628cb
a92722a
b89fdc4
a25b409
756dde8
078ed83
62ba94e
4c0adce
2aede21
f5e2757
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,8 +243,9 @@ def runtest(self): | |
this makes content checking much faster on big files (NGS > 1 GB files) | ||
were we are looking for multiple words (variants / sequences). """ | ||
# Wait for thread to complete. | ||
if self.parent.file_not_found: | ||
pytest.skip(f"'{self.content_name}' not found so cant be searched") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self.parent.thread.join() | ||
assert not self.parent.file_not_found | ||
if self.regex: | ||
assert ((self.string in self.parent.found_patterns) == | ||
self.should_contain) | ||
|
@@ -253,17 +254,9 @@ def runtest(self): | |
self.should_contain) | ||
|
||
def repr_failure(self, excinfo, style=None): | ||
if self.parent.file_not_found: | ||
containing = ("containing" if self.should_contain else | ||
"not containing") | ||
return ( | ||
f"'{self.content_name}' does not exist and cannot be searched " | ||
f"for {containing} '{self.string}'." | ||
) | ||
else: | ||
found = "not found" if self.should_contain else "found" | ||
should = "should" if self.should_contain else "should not" | ||
return ( | ||
f"'{self.string}' was {found} in {self.content_name} " | ||
f"while it {should} be there." | ||
) | ||
found = "not found" if self.should_contain else "found" | ||
should = "should" if self.should_contain else "should not" | ||
return ( | ||
f"'{self.string}' was {found} in {self.content_name} " | ||
f"while it {should} be there." | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (C) 2018 Leiden University Medical Center | ||
# This file is part of pytest-workflow | ||
# | ||
# pytest-workflow is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# pytest-workflow is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with pytest-workflow. If not, see <https://www.gnu.org/licenses/ | ||
|
||
import textwrap | ||
|
||
SKIP_TESTS = textwrap.dedent("""\ | ||
- name: wall_test | ||
command: echo "testing" | ||
files: | ||
- path: test.txt | ||
contains: | ||
- "brie" | ||
- path: test2.txt | ||
contains: | ||
- "halloumi" | ||
must_not_contain: | ||
- "gorgonzola" | ||
|
||
- name: wall3_test | ||
command: bash -c "echo 'testing' > test3.txt" | ||
files: | ||
- path: test3.txt | ||
contains: | ||
- "kaas" | ||
must_not_contain: | ||
- "testing" | ||
""") | ||
|
||
|
||
def test_skips(pytester): | ||
pytester.makefile(".yml", test=SKIP_TESTS) | ||
result = pytester.runpytest("-v").stdout.str() | ||
assert "4 failed, 3 passed, 3 skipped" in result | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if pytest outputs "3 passed, 3 skipped, 4 failed". As the result then incorrect? Have a look at pytester's method for testing outcomes. That should be stable regardless of how pytest represents the output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you word this more clearly? Is "a skip" a thing?