feat: Add comprehensive Python testing infrastructure #18
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.
Python Testing Infrastructure Setup
Summary
This PR establishes a complete testing infrastructure for the Python project, providing all the necessary tools and configuration for developers to immediately start writing and running tests.
Changes Made
Package Management
pyproject.toml
requirements.txt
to Poetry (seepyproject_full.toml
for full dependency list)Testing Configuration
pytest Configuration:
test_*.py
and*_test.py
filesCoverage Settings:
Custom Markers:
unit
: For isolated component testsintegration
: For multi-component testsslow
: For long-running tests (can be excluded with-m "not slow"
)Directory Structure
Test Fixtures (conftest.py)
Comprehensive fixtures for common testing needs:
temp_dir
,temp_file
,sample_html_file
test_config
,env_vars
mock_database
,mock_elasticsearch
,mock_tor_session
sample_onion_data
,sample_bitcoin_addresses
,sample_email_addresses
mock_port_scanner
,mock_whatweb_output
assert_helpers
,benchmark_timer
,frozen_time
Development Commands
poetry run test
- Run all testspoetry run tests
- Alternative command (both work)-v
,-k
,-m
).gitignore Updates
Added entries for:
.pytest_cache/
,.coverage
,htmlcov/
,coverage.xml
).claude/*
)How to Use
Installation
Running Tests
Writing New Tests
tests/unit/
ortests/integration/
conftest.py
for common needs@pytest.mark.unit
,@pytest.mark.integration
,@pytest.mark.slow
)test_*.py
for test files,test_*
for test functionsValidation
The infrastructure has been validated with 13 passing tests that verify:
Next Steps
requirements.txt
to Poetry (usepyproject_full.toml
as reference)Notes
pyproject.toml