Skip to content

Testing

Raphael Constantinis edited this page Jul 23, 2025 · 2 revisions

Testing Guidelines

This page describes testing recommendations for the entropic_measurement library.

Types of tests

  • Unit tests: Each function (e.g. shannon_entropy) tested in isolation
  • Integration tests: Verifies end-to-end workflows (reading, config, calculation)
  • Performance tests: Benchmarking time, memory usage for large data

Recommended structure

  • Place tests in a tests/ directory
  • Use pytest (or unittest)
    • e.g., pytest tests/

Example unit test

from entropic_measurement import shannon_entropy

def test_shannon_entropy_binary():
    data = [0.5, 0.5]
    assert shannon_entropy(data) == 1.0

Tips

  • Include edge cases (zero probability, degenerate distributions, etc.)
  • Add compatibility tests for multiple Python versions if needed
  • Test with both real and synthetic data samples
  • Use simple test datasets for sanity checks

Coverage & Automation

  • Use a tool like coverage to check test coverage (e.g., coverage run -m pytest)
  • Automate tests (e.g., with GitHub Actions or another CI)

Clone this wiki locally