How to Write Pytest Plugins
summary
Shows how to implement a concrete pytest plugin that emits a CSV of test IDs, docstrings and markers by tapping pytest_collection_modifyitems and calling pytest.exit to stop after report generation, and a second plugin that generates a self-contained HTML via pytest-html, then uploads it to Google Cloud Storage at tryfirst ordered session_finish. Includes code snippets for setup.py entry_points, uses google-cloud-storage client, and reports successful uploads with date-based bucket paths.
AI-written summary · about
chapters (8)
- 0:00Introduction to pytest
- 1:22Overview of pytest plugins
- 3:02Fixtures and local plugins
- 6:10Understanding pytest hooks
- 8:55Building a custom test plan
- 16:07Creating installable plugins
- 17:00Integrating with external tools
- 22:59Summary and resources
related talks
32mWrite Less and Test More with Data Regression Testing
32mpytest for unittesters
27mPyTest
05mStart Testing in 5 Minutes Flat
41mThe hook-based plugin architecture of py.test
03h 02mdef test_crash_course_with_pytest()
23mQt and Python; code easily using the Pytest framework
28mEgad! How Do We Start Writing Better Tests?
