@@ -115,30 +115,57 @@ class Node(metaclass=NodeMeta):
115
115
"__dict__" ,
116
116
)
117
117
118
+ name : str
119
+ parent : Optional ["Node" ]
120
+ config : Config
121
+ session : "Session"
122
+ fs_path : Path
123
+ _nodeid : str
124
+
118
125
def __init__ (
119
126
self ,
120
127
* ,
121
128
name : str ,
122
129
parent : Optional ["Node" ],
123
- config : Config ,
124
- session : "Session" ,
125
- fs_path : Path ,
126
- nodeid : str ,
130
+ config : Optional [ Config ] ,
131
+ session : Optional [ "Session" ] ,
132
+ fs_path : Optional [ Path ] ,
133
+ nodeid : Optional [ str ] ,
127
134
) -> None :
128
135
#: A unique name within the scope of the parent node.
129
136
self .name = name
137
+
138
+ if nodeid is not None :
139
+ assert "::()" not in nodeid
140
+ else :
141
+ assert parent is not None
142
+ nodeid = parent .nodeid
143
+ if name != "()" :
144
+ nodeid = f"{ nodeid } ::{ name } "
130
145
self ._nodeid = nodeid
131
146
#: The parent collector node.
132
147
self .parent = parent
133
148
134
149
#: The pytest config object.
135
- self .config = config
150
+ if config is None :
151
+ assert parent is not None
152
+ self .config = parent .config
153
+ else :
154
+ self .config = config
136
155
137
156
#: The pytest session this node is part of.
138
- self .session = session
157
+ if session is None :
158
+ assert parent is not None
159
+ self .session = parent .session
160
+ else :
161
+ self .session = session
139
162
140
163
#: Filesystem path where this node was collected from (can be None).
141
- self .fs_path = fs_path
164
+ if fs_path is None :
165
+ assert parent is not None
166
+ self .fs_path = parent .fs_path
167
+ else :
168
+ self .fs_path = fs_path
142
169
143
170
#: Keywords/markers collected from all scopes.
144
171
self .keywords = NodeKeywords (self )
@@ -509,6 +536,17 @@ def _check_initialpaths_for_relpath(
509
536
510
537
511
538
class FSCollector (Collector ):
539
+ def __init__ (self , ** kw ):
540
+
541
+ fs_path : Optional [Path ] = kw .pop ("fs_path" , None )
542
+ fspath : Optional [py .path .local ] = kw .pop ("fspath" , None )
543
+
544
+ if fspath is not None :
545
+ assert fs_path is None
546
+ fs_path = Path (fspath )
547
+ kw ["fs_path" ] = fs_path
548
+ super ().__init__ (** kw )
549
+
512
550
@classmethod
513
551
def from_parent (
514
552
cls ,
0 commit comments