@@ -402,7 +402,7 @@ def _matches_prefix_or_glob_option(self, option_name: str, name: str) -> bool:
402
402
return True
403
403
return False
404
404
405
- def collect (self ) -> Iterable [nodes .Item | nodes .Collector ]:
405
+ def collect (self ) -> Iterable [nodes .Definition | nodes .Collector ]:
406
406
if not getattr (self .obj , "__test__" , True ):
407
407
return []
408
408
@@ -415,10 +415,10 @@ def collect(self) -> Iterable[nodes.Item | nodes.Collector]:
415
415
# In each class, nodes should be definition ordered.
416
416
# __dict__ is definition ordered.
417
417
seen : set [str ] = set ()
418
- dict_values : list [list [nodes .Item | nodes .Collector ]] = []
418
+ dict_values : list [list [nodes .Definition | nodes .Collector ]] = []
419
419
ihook = self .ihook
420
420
for dic in dicts :
421
- values : list [nodes .Item | nodes .Collector ] = []
421
+ values : list [nodes .Definition | nodes .Collector ] = []
422
422
# Note: seems like the dict can change during iteration -
423
423
# be careful not to remove the list() without consideration.
424
424
for name , obj in list (dic .items ()):
@@ -564,7 +564,7 @@ class Module(nodes.File, PyCollector):
564
564
def _getobj (self ) -> types .ModuleType :
565
565
return importtestmodule (self .path , self .config )
566
566
567
- def collect (self ) -> Iterable [nodes .Item | nodes . Collector ]:
567
+ def collect (self ) -> Iterable [nodes .Collector ]:
568
568
self ._register_setup_module_fixture ()
569
569
self ._register_setup_function_fixture ()
570
570
self .session ._fixturemanager .parsefactories (self )
@@ -771,7 +771,7 @@ def from_parent(cls, parent: nodes.Node, *, name: str, **kw: Any) -> Self: # ty
771
771
def newinstance (self ) -> Any :
772
772
return self .obj ()
773
773
774
- def collect (self ) -> Iterable [nodes .Item | nodes . Collector ]:
774
+ def collect (self ) -> Iterable [nodes .Collector ]:
775
775
if not safe_getattr (self .obj , "__test__" , True ):
776
776
return []
777
777
if hasinit (self .obj ):
@@ -1132,6 +1132,8 @@ class Metafunc:
1132
1132
test function is defined.
1133
1133
"""
1134
1134
1135
+ definition : FunctionDefinition
1136
+
1135
1137
def __init__ (
1136
1138
self ,
1137
1139
definition : FunctionDefinition ,
@@ -1708,6 +1710,8 @@ class FunctionDefinition(Function):
1708
1710
"""This class is a stop gap solution until we evolve to have actual function
1709
1711
definition nodes and manage to get rid of ``metafunc``."""
1710
1712
1713
+ parent : Module | Class
1714
+
1711
1715
def runtest (self ) -> None :
1712
1716
raise RuntimeError ("function definitions are not supposed to be run as tests" )
1713
1717
0 commit comments