Skip to content

Commit 57e589d

Browse files
authored
Merge pull request #9 from jaraco/feature/simple-item
Simply construct a CheckdocsItem if any Python project file is found.
2 parents 42a50c4 + 7f3ba3b commit 57e589d

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

pytest_checkdocs/__init__.py

+7-23
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from jaraco.functools import pass_none
99

1010

11+
project_files = 'setup.py', 'setup.cfg', 'pyproject.toml'
12+
13+
1114
def pytest_collect_file(path, parent):
12-
"""Filter files down to which ones should be checked."""
13-
return (
14-
CheckdocsItem.from_parent(parent, fspath=path)
15-
if path.basename == 'setup.py'
16-
else None
17-
)
15+
if path.basename not in project_files:
16+
return
17+
return CheckdocsItem.from_parent(parent, name='project')
1818

1919

2020
class Description(str):
@@ -37,23 +37,7 @@ def repair_field(raw):
3737
return textwrap.dedent(' ' * 8 + raw)
3838

3939

40-
class CheckdocsItem(pytest.Item, pytest.File):
41-
def __init__(self, fspath, parent):
42-
# ugly hack to add support for fspath parameter
43-
# Ref pytest-dev/pytest#6928
44-
super().__init__(fspath, parent)
45-
46-
@classmethod
47-
def from_parent(cls, parent, fspath):
48-
"""
49-
Compatibility shim to support
50-
"""
51-
try:
52-
return super().from_parent(parent, fspath=fspath)
53-
except AttributeError:
54-
# pytest < 5.4
55-
return cls(fspath, parent)
56-
40+
class CheckdocsItem(pytest.Item):
5741
def runtest(self):
5842
desc = self.get_long_description()
5943
method_name = f"run_{re.sub('[-/]', '_', desc.content_type)}"

0 commit comments

Comments
 (0)