(config: Config, session: Session)
| 1532 | |
| 1533 | |
| 1534 | def _showfixtures_main(config: Config, session: Session) -> None: |
| 1535 | import _pytest.config |
| 1536 | |
| 1537 | session.perform_collect() |
| 1538 | curdir = Path.cwd() |
| 1539 | tw = _pytest.config.create_terminal_writer(config) |
| 1540 | verbose = config.getvalue("verbose") |
| 1541 | |
| 1542 | fm = session._fixturemanager |
| 1543 | |
| 1544 | available = [] |
| 1545 | seen: Set[Tuple[str, str]] = set() |
| 1546 | |
| 1547 | for argname, fixturedefs in fm._arg2fixturedefs.items(): |
| 1548 | assert fixturedefs is not None |
| 1549 | if not fixturedefs: |
| 1550 | continue |
| 1551 | for fixturedef in fixturedefs: |
| 1552 | loc = getlocation(fixturedef.func, str(curdir)) |
| 1553 | if (fixturedef.argname, loc) in seen: |
| 1554 | continue |
| 1555 | seen.add((fixturedef.argname, loc)) |
| 1556 | available.append( |
| 1557 | ( |
| 1558 | len(fixturedef.baseid), |
| 1559 | fixturedef.func.__module__, |
| 1560 | _pretty_fixture_path(fixturedef.func), |
| 1561 | fixturedef.argname, |
| 1562 | fixturedef, |
| 1563 | ) |
| 1564 | ) |
| 1565 | |
| 1566 | available.sort() |
| 1567 | currentmodule = None |
| 1568 | for baseid, module, prettypath, argname, fixturedef in available: |
| 1569 | if currentmodule != module: |
| 1570 | if not module.startswith("_pytest."): |
| 1571 | tw.line() |
| 1572 | tw.sep("-", f"fixtures defined from {module}") |
| 1573 | currentmodule = module |
| 1574 | if verbose <= 0 and argname.startswith("_"): |
| 1575 | continue |
| 1576 | tw.write(f"{argname}", green=True) |
| 1577 | if fixturedef.scope != "function": |
| 1578 | tw.write(" [%s scope]" % fixturedef.scope, cyan=True) |
| 1579 | tw.write(f" -- {prettypath}", yellow=True) |
| 1580 | tw.write("\n") |
| 1581 | doc = inspect.getdoc(fixturedef.func) |
| 1582 | if doc: |
| 1583 | write_docstring(tw, doc.split("\n\n")[0] if verbose <= 0 else doc) |
| 1584 | else: |
| 1585 | tw.line(" no docstring available", red=True) |
| 1586 | tw.line() |
| 1587 | |
| 1588 | |
| 1589 | def write_docstring(tw: TerminalWriter, doc: str, indent: str = " ") -> None: |
nothing calls this directly
no test coverage detected