(
self,
name: str,
parent: Node | None = None,
config: Config | None = None,
session: Session | None = None,
fspath: None = None,
path: Path | None = None,
nodeid: str | None = None,
)
| 145 | ) |
| 146 | |
| 147 | def __init__( |
| 148 | self, |
| 149 | name: str, |
| 150 | parent: Node | None = None, |
| 151 | config: Config | None = None, |
| 152 | session: Session | None = None, |
| 153 | fspath: None = None, |
| 154 | path: Path | None = None, |
| 155 | nodeid: str | None = None, |
| 156 | ) -> None: |
| 157 | #: A unique name within the scope of the parent node. |
| 158 | self.name: str = name |
| 159 | |
| 160 | #: The parent collector node. |
| 161 | self.parent = parent |
| 162 | |
| 163 | if config: |
| 164 | #: The pytest config object. |
| 165 | self.config: Config = config |
| 166 | else: |
| 167 | if not parent: |
| 168 | raise TypeError("config or parent must be provided") |
| 169 | self.config = parent.config |
| 170 | |
| 171 | if session: |
| 172 | #: The pytest session this node is part of. |
| 173 | self.session: Session = session |
| 174 | else: |
| 175 | if not parent: |
| 176 | raise TypeError("session or parent must be provided") |
| 177 | self.session = parent.session |
| 178 | |
| 179 | if path is None: |
| 180 | assert parent is not None |
| 181 | path = parent.path |
| 182 | #: Filesystem path where this node was collected from. |
| 183 | self.path: pathlib.Path = path |
| 184 | |
| 185 | # The explicit annotation is to avoid publicly exposing NodeKeywords. |
| 186 | #: Keywords/markers collected from all scopes. |
| 187 | self.keywords: MutableMapping[str, Any] = NodeKeywords(self) |
| 188 | |
| 189 | #: The marker objects belonging to this node. |
| 190 | self.own_markers: list[Mark] = [] |
| 191 | |
| 192 | #: Allow adding of extra keywords to use for matching. |
| 193 | self.extra_keyword_matches: set[str] = set() |
| 194 | |
| 195 | if nodeid is not None: |
| 196 | assert "::()" not in nodeid |
| 197 | self._nodeid = nodeid |
| 198 | else: |
| 199 | if not self.parent: |
| 200 | raise TypeError("nodeid or parent must be provided") |
| 201 | self._nodeid = self.parent.nodeid + "::" + self.name |
| 202 | |
| 203 | #: A place where plugins can store information on the node for their |
| 204 | #: own use. |
no test coverage detected