platform-kendryte210
platform-kendryte210 copied to clipboard
feat: Add comprehensive Python testing infrastructure
Add Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Kendryte210 platform project, providing developers with everything needed to write and run tests effectively.
Changes Made
Package Management
- Added Poetry configuration in
pyproject.tomlwith proper project metadata fromplatform.json - Configured development dependencies:
pytest,pytest-cov,pytest-mock - Set up proper Python packaging with packages and include specifications
Testing Configuration
- pytest configuration with comprehensive settings in
pyproject.toml:- Test discovery patterns for
test_*.pyand*_test.pyfiles - Custom markers:
unit,integration,slow - Strict configuration for reliable testing
- Test discovery patterns for
- Coverage reporting configured with:
- 80% coverage threshold requirement
- HTML reports in
htmlcov/directory - XML reports for CI/CD integration
- Proper exclusions for test files, examples, and virtual environments
Directory Structure
tests/directory with proper Python package structuretests/unit/andtests/integration/subdirectories for organized testingtests/conftest.pywith comprehensive shared fixtures:temp_dir: Temporary directory for test filesmock_platform_config: Mock platform configuration datamock_board_config: Mock board configuration datamock_platformio_env: Mock PlatformIO environment- Sample file fixtures for testing
Validation Tests
- Setup validation tests in
tests/test_setup_validation.py:- Python version compatibility checks
- Project structure validation
- Configuration file validation
- Import capability testing
- Fixture functionality verification
Development Environment
- Updated
.gitignorewith testing-related entries and Claude Code settings - Poetry lock file for reproducible dependency management
Running Tests
Installation
poetry install
Running Tests
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov
# Run specific test types
poetry run pytest -m unit # Only unit tests
poetry run pytest -m integration # Only integration tests
poetry run pytest -m "not slow" # Exclude slow tests
# Run with verbose output
poetry run pytest -v
# Generate coverage report
poetry run pytest --cov --cov-report=html
Coverage Reports
- Terminal: Coverage summary displayed after test runs
- HTML: Open
htmlcov/index.htmlin browser for detailed coverage report - XML:
coverage.xmlfor CI/CD integration
Infrastructure Features
- 80% coverage threshold ensures code quality
- Multiple test markers for flexible test organization
- Comprehensive fixtures for platform and board testing
- Proper exclusions prevent coverage pollution from test files
- Reproducible environment via Poetry lock file
Next Steps
Developers can now:
- Write unit tests in
tests/unit/ - Write integration tests in
tests/integration/ - Use provided fixtures for consistent test setup
- Run tests with confidence in the infrastructure
- Monitor code coverage to maintain quality standards
The testing infrastructure is ready for immediate use and follows Python testing best practices.