russian-cities
russian-cities copied to clipboard
feat: set up comprehensive Python testing infrastructure
Set up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Russian Cities Parser project, providing developers with a ready-to-use testing environment.
Changes Made
Package Management
- Set up Poetry as the primary package manager with
pyproject.tomlconfiguration - Migrated dependencies from
requirements.txtto Poetry (parselab, lxml) - Added testing dependencies: pytest, pytest-cov, pytest-mock as development dependencies
Testing Configuration
- pytest configuration in
pyproject.tomlwith:- Test discovery patterns for flexible test file naming
- Coverage reporting with 80% threshold
- HTML and XML coverage report generation
- Custom markers:
unit,integration,slow - Strict configuration for better test reliability
Directory Structure
- Created proper testing hierarchy:
tests/ ├── __init__.py ├── conftest.py ├── unit/ │ └── __init__.py ├── integration/ │ └── __init__.py └── test_infrastructure_validation.py
Shared Test Fixtures
- Comprehensive fixtures in
conftest.pyincluding:- Temporary directory and file fixtures
- Mock environment variables
- Sample data fixtures for Russian cities
- Mock network responses for testing web scraping
- Cache and network manager mocks
Development Tools
- Updated
.gitignorewith testing artifacts, build files, IDE files - Validation tests to ensure infrastructure works correctly
- Coverage configuration excluding test files and virtual environments
Testing Infrastructure Features
Running Tests
# Install dependencies
poetry install
# Run all tests
poetry run pytest
# Run tests without coverage threshold failure
poetry run pytest --cov-fail-under=0
# Run only unit tests
poetry run pytest -m unit
# Run only integration tests
poetry run pytest -m integration
Coverage Reporting
- Terminal output with missing line indicators
- HTML report generated in
htmlcov/directory - XML report for CI/CD integration (
coverage.xml) - Configurable threshold (currently set to 80%)
Test Organization
- Unit tests:
tests/unit/for isolated component testing - Integration tests:
tests/integration/for end-to-end testing - Custom markers for categorizing and filtering tests
- Shared fixtures for common test scenarios
Validation
✅ All infrastructure validation tests pass (8/8)
✅ Coverage reports generate correctly (HTML + XML)
✅ Poetry dependency management works
✅ Test discovery and execution work as expected
✅ Fixtures are properly configured and accessible
Next Steps
Developers can now:
- Write unit tests in
tests/unit/for individual functions and classes - Write integration tests in
tests/integration/for complete workflows - Use provided fixtures for common testing scenarios
- Run tests with coverage to ensure code quality
- Add custom markers for specific test categories
The infrastructure is ready for immediate use - just start writing tests!
🤖 Generated with Claude Code