pip install -r requirements.txtpytestpytest --cov=pysiology --cov-report=htmltests/
├── __init__.py # Test package
├── conftest.py # Shared fixtures
├── test_electromyography.py # EMG tests (249 lines)
├── test_electrocardiography.py # ECG tests (183 lines)
├── test_electrodermalactivity.py # GSR tests (124 lines)
├── test_utils.py # Utility tests (140 lines)
└── README.md # Detailed test documentation
| Module | Test Classes | Test Cases | Coverage |
|---|---|---|---|
| electromyography | 6 | ~60+ | Time/Freq domain, filtering |
| electrocardiography | 4 | ~20+ | HRV, frequency analysis |
| electrodermalactivity | 5 | ~15+ | Filtering, peak detection, SCR |
| utils | 3 | ~13 | Correlation analysis, validation |
| Total | 18 | 100+ | All modules |
pytest tests/test_electromyography.py -vpytest tests/test_electromyography.py::TestTimeDomainFeatures -vpytest tests/test_electromyography.py::TestTimeDomainFeatures::test_getIEMG -vpytest -vv --tb=longpytest -xpytest --lf --maxfail=5pytest --cov=pysiology --cov-report=html
open htmlcov/index.htmlsample_emg_signal: Synthetic EMG with 50Hz + 100Hz componentssample_ecg_signal: ECG simulation with heart ratesample_gsr_signal: GSR with baseline and phasic activitysample_signals_for_correlation: Multiple correlated signalssample_peaks: Synthetic peak indices
- ✓ Feature calculation correctness
- ✓ Output type validation
- ✓ Output range validation
- ✓ Input error handling
- ✓ Edge cases
- ✓ Signal processing pipeline integrity
Tests run automatically on:
- Push to
masterordevelopbranches - Pull requests to
masterordevelop - Multiple Python versions: 3.8, 3.9, 3.10, 3.11
- Coverage reports uploaded to Codecov
Template:
def test_my_feature(self, sample_emg_signal):
"""Test description."""
signal, samplerate = sample_emg_signal
result = emg.myFunction(signal)
assert isinstance(result, (int, float, np.number))
assert result >= 0, "Should be non-negative"Guidelines:
- Use descriptive names starting with
test_ - Group related tests in classes
- Use fixtures for test data
- Include meaningful assertions
- Document expected behavior
pip install -r requirements.txtpip install pytest pytest-covpytest --cov=pysiology --cov-report=html --cov-report=term-missingtests/README.md- Detailed test documentationTESTS_SUMMARY.md- Test suite overview.github/workflows/tests.yml- CI/CD configuration