Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion pytest_checkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,30 @@

def pytest_collect_file(path, parent):
"""Filter files down to which ones should be checked."""
return CheckdocsItem(path, parent) if path.basename == 'setup.py' else None
return (
CheckdocsItem.from_parent(parent, fspath=path)
if path.basename == 'setup.py'
else None
)


class CheckdocsItem(pytest.Item, pytest.File):
def __init__(self, fspath, parent):
# ugly hack to add support for fspath parameter
# Ref pytest-dev/pytest#6928
super().__init__(fspath, parent)

@classmethod
def from_parent(cls, parent, fspath):
"""
Compatibility shim to support
"""
try:
return super().from_parent(parent, fspath=fspath)
except AttributeError:
# pytest < 5.4
return cls(fspath, parent)

def runtest(self):
with self.monkey_patch_system_message() as reports:
self.rst2html(self.get_long_description())
Expand Down