8
8
from jaraco .functools import pass_none
9
9
10
10
11
+ project_files = 'setup.py' , 'setup.cfg' , 'pyproject.toml'
12
+
13
+
11
14
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' )
18
18
19
19
20
20
class Description (str ):
@@ -37,23 +37,7 @@ def repair_field(raw):
37
37
return textwrap .dedent (' ' * 8 + raw )
38
38
39
39
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 ):
57
41
def runtest (self ):
58
42
desc = self .get_long_description ()
59
43
method_name = f"run_{ re .sub ('[-/]' , '_' , desc .content_type )} "
0 commit comments