(
self,
fspath: None = None,
path_or_parent: Path | Node | None = None,
path: Path | None = None,
name: str | None = None,
parent: Node | None = None,
config: Config | None = None,
session: Session | None = None,
nodeid: str | None = None,
)
| 553 | """Base class for filesystem collectors.""" |
| 554 | |
| 555 | def __init__( |
| 556 | self, |
| 557 | fspath: None = None, |
| 558 | path_or_parent: Path | Node | None = None, |
| 559 | path: Path | None = None, |
| 560 | name: str | None = None, |
| 561 | parent: Node | None = None, |
| 562 | config: Config | None = None, |
| 563 | session: Session | None = None, |
| 564 | nodeid: str | None = None, |
| 565 | ) -> None: |
| 566 | if path_or_parent: |
| 567 | if isinstance(path_or_parent, Node): |
| 568 | assert parent is None |
| 569 | parent = cast(FSCollector, path_or_parent) |
| 570 | elif isinstance(path_or_parent, Path): |
| 571 | assert path is None |
| 572 | path = path_or_parent |
| 573 | assert path is not None |
| 574 | |
| 575 | if name is None: |
| 576 | name = path.name |
| 577 | if parent is not None and parent.path != path: |
| 578 | try: |
| 579 | rel = path.relative_to(parent.path) |
| 580 | except ValueError: |
| 581 | pass |
| 582 | else: |
| 583 | name = str(rel) |
| 584 | name = norm_sep(name) |
| 585 | self.path = path |
| 586 | |
| 587 | if session is None: |
| 588 | assert parent is not None |
| 589 | session = parent.session |
| 590 | |
| 591 | if nodeid is None: |
| 592 | try: |
| 593 | nodeid = str(self.path.relative_to(session.config.rootpath)) |
| 594 | except ValueError: |
| 595 | nodeid = _check_initialpaths_for_relpath(session._initialpaths, path) |
| 596 | |
| 597 | if nodeid: |
| 598 | nodeid = norm_sep(nodeid) |
| 599 | |
| 600 | super().__init__( |
| 601 | name=name, |
| 602 | parent=parent, |
| 603 | config=config, |
| 604 | session=session, |
| 605 | nodeid=nodeid, |
| 606 | path=path, |
| 607 | ) |
| 608 | |
| 609 | @classmethod |
| 610 | def from_parent( |
nothing calls this directly
no test coverage detected