1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-25 17:38:54 +00:00

[test] Add code coverage framework

Implement a comprehensive test coverage framework that integrates with pytest-cov
to generate code coverage reports for the yt-dlp codebase. Key components:

- Configuration file (.coveragerc) with appropriate include/exclude patterns
- Helper script (run_coverage.py) with parallel report generation
- GitHub Actions workflow for automatic coverage reporting on PRs and pushes
- Support for Hatch testing environment and CLI integration
- Testing documentation for running coverage reports
- Sample test for demonstrating coverage reporting
This commit is contained in:
Wilson Bilkovich
2025-03-09 01:45:57 -05:00
parent 05c8023a27
commit 1e7c02ca48
9 changed files with 311 additions and 1 deletions

39
test/README.md Normal file
View File

@@ -0,0 +1,39 @@
# yt-dlp Tests
This directory contains tests for the yt-dlp codebase.
## Running Tests
### Using hatch (requires `pip install hatch`)
```bash
# Run tests for a specific test file
hatch run hatch-test:run test/test_utils.py
# Run a specific test class or method
hatch run hatch-test:run test/test_utils.py::TestUtil
hatch run hatch-test:run test/test_utils.py::TestUtil::test_url_basename
# Run with verbosity
hatch run hatch-test:run -- test/test_utils.py -v
```
### Using pytest directly
```bash
# Run a specific test file
python -m pytest test/test_utils.py
# Run a specific test class or method
python -m pytest test/test_utils.py::TestUtil
python -m pytest test/test_utils.py::TestUtil::test_url_basename
# Run with verbosity
python -m pytest -v test/test_utils.py
```
**Important:** Always run tests from the project root directory, not from a subdirectory.
## Code Coverage
For information on running tests with code coverage, see the documentation in `.coverage-reports/README.md`.