(
self,
name: str,
parent: "Optional[Node]" = None,
config: Optional[Config] = None,
session: "Optional[Session]" = None,
fspath: Optional[LEGACY_PATH] = None,
path: Optional[Path] = None,
nodeid: Optional[str] = None,
)
| 183 | ) |
| 184 | |
| 185 | def __init__( |
| 186 | self, |
| 187 | name: str, |
| 188 | parent: "Optional[Node]" = None, |
| 189 | config: Optional[Config] = None, |
| 190 | session: "Optional[Session]" = None, |
| 191 | fspath: Optional[LEGACY_PATH] = None, |
| 192 | path: Optional[Path] = None, |
| 193 | nodeid: Optional[str] = None, |
| 194 | ) -> None: |
| 195 | #: A unique name within the scope of the parent node. |
| 196 | self.name = name |
| 197 | |
| 198 | #: The parent collector node. |
| 199 | self.parent = parent |
| 200 | |
| 201 | if config: |
| 202 | #: The pytest config object. |
| 203 | self.config: Config = config |
| 204 | else: |
| 205 | if not parent: |
| 206 | raise TypeError("config or parent must be provided") |
| 207 | self.config = parent.config |
| 208 | |
| 209 | if session: |
| 210 | #: The pytest session this node is part of. |
| 211 | self.session = session |
| 212 | else: |
| 213 | if not parent: |
| 214 | raise TypeError("session or parent must be provided") |
| 215 | self.session = parent.session |
| 216 | |
| 217 | if path is None and fspath is None: |
| 218 | path = getattr(parent, "path", None) |
| 219 | #: Filesystem path where this node was collected from (can be None). |
| 220 | self.path: Path = _imply_path(type(self), path, fspath=fspath) |
| 221 | |
| 222 | # The explicit annotation is to avoid publicly exposing NodeKeywords. |
| 223 | #: Keywords/markers collected from all scopes. |
| 224 | self.keywords: MutableMapping[str, Any] = NodeKeywords(self) |
| 225 | |
| 226 | #: The marker objects belonging to this node. |
| 227 | self.own_markers: List[Mark] = [] |
| 228 | |
| 229 | #: Allow adding of extra keywords to use for matching. |
| 230 | self.extra_keyword_matches: Set[str] = set() |
| 231 | |
| 232 | if nodeid is not None: |
| 233 | assert "::()" not in nodeid |
| 234 | self._nodeid = nodeid |
| 235 | else: |
| 236 | if not self.parent: |
| 237 | raise TypeError("nodeid or parent must be provided") |
| 238 | self._nodeid = self.parent.nodeid + "::" + self.name |
| 239 | |
| 240 | #: A place where plugins can store information on the node for their |
| 241 | #: own use. |
| 242 | #: |
no test coverage detected