This repository has been archived by the owner on Mar 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove hacky test-skipping workaround now that pytest-dev/pytest#568 has been fixed
- Loading branch information
1 parent
0f9a0f8
commit 088bfa8
Showing
6 changed files
with
22 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
lz4==2.0.2 | ||
lz4tools==1.3.1.2 | ||
pytest | ||
pytest==3.6.3 | ||
pytest-cov | ||
python-snappy | ||
mock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +0,0 @@ | ||
import pytest | ||
|
||
|
||
def patch_subclass(parent, skip_condition): | ||
"""Work around a pytest.mark.skipif bug | ||
https://github.com/pytest-dev/pytest/issues/568 | ||
The issue causes all subclasses of a TestCase subclass to be skipped if any one | ||
of them is skipped. | ||
This fix circumvents the issue by overriding Python's existing subclassing mechanism. | ||
Instead of having `cls` be a subclass of `parent`, this decorator adds each attribute | ||
of `parent` to `cls` without using Python inheritance. When appropriate, it also adds | ||
a boolean condition under which to skip tests for the decorated class. | ||
:param parent: The "superclass" from which the decorated class should inherit | ||
its non-overridden attributes | ||
:type parent: unittest2.TestCase | ||
:param skip_condition: A boolean condition that, when True, will cause all tests in | ||
the decorated class to be skipped | ||
:type skip_condition: bool | ||
""" | ||
def patcher(cls): | ||
def build_skipped_method(method, cls, cond=None): | ||
if cond is None: | ||
cond = False | ||
if hasattr(method, "skip_condition"): | ||
cond = cond or method.skip_condition(cls) | ||
|
||
@pytest.mark.skipif(cond, reason="") | ||
def _wrapper(self): | ||
return method(self) | ||
return _wrapper | ||
|
||
# two passes over parent required so that skips have access to all class | ||
# attributes | ||
for attr in parent.__dict__: | ||
if attr in cls.__dict__: | ||
continue | ||
if not attr.startswith("test_"): | ||
setattr(cls, attr, parent.__dict__[attr]) | ||
|
||
for attr in cls.__dict__: | ||
if attr.startswith("test_"): | ||
setattr(cls, attr, build_skipped_method(cls.__dict__[attr], | ||
cls, skip_condition)) | ||
|
||
for attr in parent.__dict__: | ||
if attr.startswith("test_"): | ||
setattr(cls, attr, build_skipped_method(parent.__dict__[attr], | ||
cls, skip_condition)) | ||
return cls | ||
return patcher | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters