-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customize pytest collection to ignore feditest objects. (#274)
Co-authored-by: Steve Bate <svc-atlassian@stevebate.net>
- Loading branch information
1 parent
240d742
commit e6ff705
Showing
2 changed files
with
22 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# def pytest_pycollect_makeitem(collector, name, obj): | ||
# module_name = getattr(obj, "__module__") if hasattr(obj, "__module__") else None | ||
# if module_name and module_name.startswith("feditest."): | ||
# print("@@@@@ Not collecting", obj, module_name) | ||
# return None | ||
|
||
import inspect | ||
|
||
import pytest | ||
|
||
|
||
@pytest.hookimpl(wrapper=True) | ||
def pytest_pycollect_makeitem(collector, name, obj): | ||
# Ignore all feditest classes and function using | ||
# pytest naming conventions. | ||
if isinstance(obj, type) or inspect.isfunction(obj) or inspect.ismethod(obj): | ||
m = obj.__module__.split(".") | ||
if len(m) > 0 and m[0] == "feditest": | ||
yield | ||
return None | ||
result = yield | ||
return result |