Skip to content

tests: add representative fixture suite#1720

Open
ZeliardM wants to merge 10 commits into
python-kasa:masterfrom
ZeliardM:diagnose-windows-xdist-hang
Open

tests: add representative fixture suite#1720
ZeliardM wants to merge 10 commits into
python-kasa:masterfrom
ZeliardM:diagnose-windows-xdist-hang

Conversation

@ZeliardM

@ZeliardM ZeliardM commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace Windows-specific pytest sharding with a two-tier fixture test strategy
  • run a deterministic representative fixture suite across Python 3.11?3.14 on Ubuntu, Ubuntu with all extras, macOS, and Windows
  • run the complete fixture-expanded suite first on Ubuntu/Python 3.14 with all optional dependencies
  • gate the representative matrix on the successful full-suite job
  • select representatives independently per test from protocol, model, component, component-version, discovery, parent/child, and response-shape traits
  • provide marker overrides for exhaustive fixture contracts and broader representative pools
  • remove two unnecessary dev dependencies from generic feature unit tests
  • document the fixture tiers and contributor workflow in tests/README.md

Why

The test suite has 203 captured device fixtures and previously expanded most generic behavior tests across every matching fixture. Device fixtures accounted for 22,182 of 23,066 collected cases, and 56 generic functions running against all 183 primary fixtures produced 11,163 cases by themselves.

The old CI matrix executed the complete suite approximately 16 times?roughly 369,000 pytest case executions per commit. Fixture growth automatically multiplied that workload and repeatedly exposed Windows/xdist instability.

Generic compatibility behavior does not need every firmware response on every operating system and Python version. Fixture-specific parsing and behavior still need exhaustive validation. This change separates those responsibilities instead of trying to make Windows execute the entire combinatorial suite reliably.

Fixture tiers

--fixture-set representative retains all non-fixture parametrization and selects up to six diverse fixtures independently for each broadly parametrized test. Protocols present in a pool receive a reserved representative before a deterministic greedy set-cover pass selects additional capability-diverse fixtures. Pools of six or fewer fixtures are unchanged, preserving focused regression parametrization.

--fixture-set all bypasses selection and remains the default for local uv run pytest, preserving existing exhaustive behavior unless representative mode is explicitly requested.

Tests can use @pytest.mark.all_fixtures to remain exhaustive in representative mode or @pytest.mark.fixture_representatives(limit) to request a broader per-test representative pool.

CI structure

The required execution order is:

  1. Perform Lint Checks (3.14)
  2. Preform Full Test Suite (3.14) on Ubuntu with all extras and --fixture-set all
  3. A combined representative matrix containing:
    • Ubuntu Python 3.11?3.14
    • Ubuntu with all extras Python 3.11?3.14
    • macOS Python 3.11?3.14
    • Windows Python 3.11?3.14

The representative matrix uses fail-fast: false, so all platform/version results remain visible if one combination fails. All Windows shard planning, batching, temp coverage, and artifact coordination are removed.

The representative tier currently contains 3,259 cases and the exhaustive tier contains 22,708. Expected PR execution falls from roughly 369,000 cases to approximately 74,900 while retaining one complete fixture-expanded run and representative all-extras coverage on every supported Python version.

Required-check configuration

After merge, a maintainer with repository settings access must update the branch-protection/ruleset required check from Python 3.13 on ubuntu-latest (extras) to Preform Full Test Suite (3.14). The existing Python 3.13 Ubuntu extras check remains present in the representative matrix, but the intended required gate is now the exhaustive full-suite job.

Validation

  • representative collection is identical on Python 3.11, 3.12, 3.13, and 3.14: 3,259 cases each
  • exhaustive collection contains 22,708 cases
  • six selector unit tests pass on every supported Python version
  • selector tests cover deterministic ordering, limits, protocol preservation, component diversity, nested fixture parameters, and invalid limits
  • representative CLI, discovery, device, device-factory, and feature tests: 617 passed and 8 skipped in 16 seconds
  • the ordered exhaustive gate and all 16 representative Ubuntu, Ubuntu extras, macOS, and Windows jobs passed in GitHub Actions run 29131428908
  • all repository pre-commit hooks pass, including Ruff, Ruff format, mypy, YAML checks, and generated-device validation
  • workflow YAML parsing, the 16-combination matrix assertion, dependency-chain assertions, and git diff --check pass

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.21%. Comparing base (8c66d0a) to head (22efa49).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1720   +/-   ##
=======================================
  Coverage   93.21%   93.21%           
=======================================
  Files         157      157           
  Lines        9819     9819           
  Branches     1005     1005           
=======================================
  Hits         9153     9153           
  Misses        472      472           
  Partials      194      194           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ZeliardM
ZeliardM marked this pull request as ready for review July 10, 2026 20:01
@ZeliardM ZeliardM changed the title ci: shard Windows pytest jobs tests: add representative fixture suite Jul 10, 2026
@ZeliardM

Copy link
Copy Markdown
Collaborator Author

Maintainer action required after this PR is merged: please update the branch-protection/ruleset required check from Python 3.13 on ubuntu-latest (extras) to Preform Full Test Suite (3.14).

The existing Python 3.13 Ubuntu extras check is present again in the representative matrix for compatibility, but the new intended required gate is the exhaustive Python 3.14 Ubuntu job with all extras.

The workflow order is now:

  1. Perform Lint Checks (3.14)
  2. Preform Full Test Suite (3.14)
  3. The 16 representative Ubuntu, Ubuntu extras, macOS, and Windows jobs across Python 3.11–3.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant