Skip to content

Add a test suite (unit + regression) #44

Description

@shreyasgm

The package currently has no tests. Every refactor in the modernization tiers (#41, #42, #43) is risky without them, and users keep hitting correctness questions (#8, #19, #21, #23, #25, #38, #39) that we can't answer decisively without reproducible fixtures.

Goals

  1. Lock in current behavior before we refactor, so we can prove "no behavior change" commits.
  2. Cover the known numerical pitfalls so correctness regressions are caught automatically.
  3. Run in CI on every PR.

Scope

Infrastructure

  • Add pytest, pytest-cov, and hypothesis (for property tests) as a [test] extra.
  • tests/ directory layout; conftest.py with fixtures.
  • GitHub Actions workflow running on 3.10 / 3.11 / 3.12.

Fixtures

  • A small synthetic trade panel (~5 countries, ~10 products, 3 years) checked in as CSV. Hand-computed or independently-computed expected values for RCA, MCP, diversity/ubiquity, proximity, and ECI/PCI.
  • A larger golden-file regression fixture: run the current main on a real sample (e.g. a subset of SITC 2-digit) and snapshot the output dataframe. Compare to tolerance on every PR.

Unit tests

Integration / golden tests

Property tests (hypothesis)

  • RCA is non-negative.
  • MCP ∈ {0, 1}.
  • ECI has mean ≈ 0 and std ≈ 1 after normalization.
  • Proximity matrix is symmetric when asymmetric=False and has values in [0, 1].
  • Output row count = locs × prods × years (rectangularized).

Edge cases from open issues

Acceptance

  • pytest runs clean locally and in CI.
  • Coverage ≥ 80% on ecomplexity/.
  • Regression test catches at least one of the known open bugs (used as a red-green check).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions