Perform the collection phase for the given session. Stops at first non-None result, see :ref:`firstresult`. The return value is not used, but only stops further processing. The default collection phase is this (see individual hooks for full details): 1. Starting from ``session`` a
(session: "Session")
| 206 | |
| 207 | @hookspec(firstresult=True) |
| 208 | def pytest_collection(session: "Session") -> Optional[object]: |
| 209 | """Perform the collection phase for the given session. |
| 210 | |
| 211 | Stops at first non-None result, see :ref:`firstresult`. |
| 212 | The return value is not used, but only stops further processing. |
| 213 | |
| 214 | The default collection phase is this (see individual hooks for full details): |
| 215 | |
| 216 | 1. Starting from ``session`` as the initial collector: |
| 217 | |
| 218 | 1. ``pytest_collectstart(collector)`` |
| 219 | 2. ``report = pytest_make_collect_report(collector)`` |
| 220 | 3. ``pytest_exception_interact(collector, call, report)`` if an interactive exception occurred |
| 221 | 4. For each collected node: |
| 222 | |
| 223 | 1. If an item, ``pytest_itemcollected(item)`` |
| 224 | 2. If a collector, recurse into it. |
| 225 | |
| 226 | 5. ``pytest_collectreport(report)`` |
| 227 | |
| 228 | 2. ``pytest_collection_modifyitems(session, config, items)`` |
| 229 | |
| 230 | 1. ``pytest_deselected(items)`` for any deselected items (may be called multiple times) |
| 231 | |
| 232 | 3. ``pytest_collection_finish(session)`` |
| 233 | 4. Set ``session.items`` to the list of collected items |
| 234 | 5. Set ``session.testscollected`` to the number of collected items |
| 235 | |
| 236 | You can implement this hook to only perform some action before collection, |
| 237 | for example the terminal plugin uses it to start displaying the collection |
| 238 | counter (and returns `None`). |
| 239 | |
| 240 | :param pytest.Session session: The pytest session object. |
| 241 | """ |
| 242 | |
| 243 | |
| 244 | def pytest_collection_modifyitems( |
nothing calls this directly
no outgoing calls
no test coverage detected