feat: Set up Python testing infrastructure with Poetry and pytest #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Set Up Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the DNSChef project, migrating from Pipenv to Poetry for modern dependency management and setting up pytest as the testing framework.
Changes Made
Package Management
pyproject.tomlwith Poetry configurationdnslibfrom requirements.txtTesting Dependencies
Added the following development dependencies:
pytest(^7.4.0) - Core testing frameworkpytest-cov(^4.1.0) - Coverage reportingpytest-mock(^3.11.0) - Mocking utilitiesTesting Configuration
Configured comprehensive pytest settings in
pyproject.toml:unit,integration, andslowtest markersDirectory Structure
Created organized testing structure:
Shared Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dirandtemp_file- Temporary file handlingmock_config- DNS server configuration mockingmock_dns_query- DNS query object mockingmock_socket- Network socket mockingmock_logger- Logging mockingdns_server_config- Sample configurationssample_dns_records- Test DNS recordsreset_environment- Environment cleanupcapture_stdout- Output capturingmock_args- Command-line argument mockingDevelopment Workflow
Updated
.gitignorewith:.pytest_cache/,.coverage,htmlcov/, etc.).claude/*)poetry.lockis intentionally gitignored as this is a tool, not an applicationValidation
Created
test_setup_validation.pyto verify:How to Use
Install Dependencies
Run Tests
You can use either command:
poetry run test poetry run testsRun Specific Tests
poetry run pytest tests/unit/ poetry run pytest -m unit poetry run pytest -m "not slow"Generate Coverage Reports
Tests automatically generate coverage reports:
htmlcov/directorycoverage.xmlNotes
Next Steps
Developers can now:
tests/unit/tests/integration/