ssh-ident
ssh-ident copied to clipboard
feat: Set up complete Python testing infrastructure with Poetry
Set Up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the ssh-ident project using Poetry as the package manager and pytest as the testing framework. The setup provides a ready-to-use testing environment where developers can immediately start writing tests.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith Poetry setup in package-mode=false (since ssh-ident is a standalone script) - No Migration Required: No existing
requirements.txtorsetup.pyfiles were found
Testing Dependencies
Added as development dependencies:
pytest ^8.0.0- Core testing frameworkpytest-cov ^5.0.0- Coverage reportingpytest-mock ^3.14.0- Mocking utilities
Testing Configuration
Configured in pyproject.toml:
- pytest settings:
- Test discovery in
tests/directory - Coverage reporting (HTML, XML, terminal)
- Custom markers:
unit,integration,slow - Strict mode with verbose output
- Test discovery in
- coverage settings:
- Source coverage for project root
- Exclusions for test files, virtual envs, and build artifacts
- HTML reports in
htmlcov/, XML incoverage.xml
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_setup_validation.py # Infrastructure validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Testing Fixtures
Created comprehensive fixtures in conftest.py:
temp_dir- Temporary directory managementtemp_file- Temporary file creationmock_env_vars- Environment variable mockingmock_home_dir- Mock home directorymock_ssh_dir- Mock .ssh directorymock_config- Configuration mockingsample_ssh_key- Sample SSH key filesample_ssh_config- Sample SSH configcapture_stdout- Stdout capture utilityreset_modules- Module reset between tests
Additional Setup
Updated .gitignore with:
- Testing artifacts:
.pytest_cache/,.coverage,htmlcov/,coverage.xml - Python artifacts:
__pycache__/,*.py[cod],*.egg-info/ - Development: virtual environments, IDE files, build artifacts
- Claude settings:
.claude/*
How to Use
-
Install dependencies:
poetry install -
Run tests:
poetry run pytest -
Run tests with specific markers:
poetry run pytest -m unit poetry run pytest -m integration poetry run pytest -m "not slow" -
View coverage report:
# After running tests, open the HTML report open htmlcov/index.html
Validation
All validation tests pass successfully:
- Testing tools are installed and available
- Directory structure is created correctly
- Fixtures are working properly
- Markers are configured
- Coverage reporting is functional
Notes
- Coverage threshold is currently set to 0% to allow initial setup without failing
- The project uses Poetry in non-package mode since ssh-ident is a standalone script
- Standard pytest options are available for all test runs
- The infrastructure is ready for developers to start writing actual unit and integration tests