selenium-python
selenium-python copied to clipboard
feat: Add complete Python testing infrastructure with Poetry
Add Python Testing Infrastructure
Summary
This PR sets up a complete Python testing infrastructure for the Selenium Python documentation project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith Poetry configuration- Set
package-mode = falsesince this is a documentation-only project - Migrated dependencies from
requirements.txtandsetup.py - Added testing dependencies as dev dependencies
- Set
Testing Framework
- pytest: Main testing framework with comprehensive configuration
- pytest-cov: Coverage reporting with HTML and XML output
- pytest-mock: Mocking utilities for testing
Testing Configuration
-
pytest settings in
pyproject.toml:- Strict markers and configuration
- Custom markers:
unit,integration,slow - Test discovery patterns configured
- Coverage reporting with multiple formats
-
Coverage settings:
- Source directory configuration
- Exclusion patterns for test files and virtual environments
- Detailed reporting options
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared pytest fixtures
├── test_setup_validation.py # Infrastructure validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Fixtures Added (in conftest.py)
temp_dir: Temporary directory for test filesmock_config: Mock configuration dictionarysample_rst_content: Sample reStructuredText for testingsphinx_build_dir: Mock Sphinx build directory structuresource_dir: Mock source directory with basic Sphinx structuremock_sphinx_app: Mock Sphinx application objectreset_environment: Environment variable cleanupsample_makefile_content: Sample Makefile content
Other Updates
- Updated
.gitignorewith:- Testing artifacts (
.pytest_cache/,.coverage,htmlcov/, etc.) - Development files (virtual environments, IDE files)
- Claude settings (
.claude/*)
- Testing artifacts (
How to Use
Install Dependencies
poetry install
Run Tests
# Run all tests
poetry run pytest
# Run with verbose output
poetry run pytest -v
# Run specific markers
poetry run pytest -m unit
poetry run pytest -m integration
# Run without coverage
poetry run pytest --no-cov
View Coverage Reports
- HTML report: Open
htmlcov/index.htmlin a browser - XML report: Available at
coverage.xmlfor CI/CD integration
Validation
The setup includes validation tests that verify:
- All testing dependencies are properly installed
- Project structure is correctly set up
- Configuration files are valid and complete
- Pytest markers work correctly
- Fixtures are available and functional
- Poetry commands work as expected
All validation tests pass successfully:
============================== 12 passed in 0.47s ==============================
Notes
- This is a documentation project, so coverage requirements are relaxed
- The Poetry scripts for
testandtestscommands usepytest:mainentry point - The infrastructure is ready for developers to start writing actual tests for any Python code or utilities in the project