Skip to content

Prevent tests IDs from drifting between pytest discovery and running - #3520

Merged
deruyter92 merged 5 commits into
devfrom
cy/fix-random-test-init
Oct 22, 2026
Merged

deruyter92 merged 5 commits into
devfrom
cy/fix-random-test-init

Conversation

@C-Achard

Copy link
Copy Markdown
Member

Replaces the use of Python's random module with NumPy's random number generator seeded per test case, ensures stable test parametrization and ID generation, and clarifies test case identifiers.

Goal

  • Fixes issues related to discovering then running tests, e.g. in the VSCode test panel
  • Also increases coverage for certain low/high values that were otherwise hit randomly

Replace random test inputs with deterministic fixtures and stable pytest ids across the pose-estimation PyTorch tests. This avoids run-after-discovery desync, which makes the tests impossible to run in e.g. the VSCode pytest extension
Assign per-case RNG seeds to the PyTorch pose estimation tests and replace a few random samples with fixed edge-case parameters. This keeps test IDs stable while covering a wider range of augmentation, batch size, and input-size combinations.
@C-Achard C-Achard self-assigned this Sep 17, 2026
@C-Achard C-Achard added enhancement New feature or request tests labels Sep 17, 2026
@C-Achard
C-Achard requested a lite review from Copilot September 17, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The resize test config contains a misspelled option key (keep_ration) that is ignored by the implementation, reducing test correctness.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR makes several PyTorch pose-estimation tests deterministic and selectable by stable pytest IDs, addressing mismatches between pytest discovery and ID-based runs (e.g., IDE test panels).

Changes:

  • Replace Python random usage in parametrized tests with per-case numpy.random.default_rng(seed) for reproducible inputs.
  • Introduce explicit, stable pytest.param(..., id=...) cases for backbones/heads/transforms and dataset augmentation scenarios.
  • Expand deterministic coverage by pinning previously-random edge cases (e.g., extreme augmentation / size combinations).
File summaries
File Description
tests/pose_estimation_pytorch/other/test_pose_model.py Adds stable IDs for backbone/head parametrizations and uses seeded NumPy RNG to generate deterministic input sizes.
tests/pose_estimation_pytorch/other/test_dataset.py Removes random parametrization, replacing it with fixed, named cases to stabilize dataset iteration tests.
tests/pose_estimation_pytorch/other/test_api_utils.py Refactors transform test cases into named configs with deterministic RNG-driven synthetic inputs and clearer exception assertions.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@C-Achard
C-Achard requested a review from deruyter92 September 17, 2026 11:57
@C-Achard C-Achard changed the title Prevent tests IDs from drifting between pytest discovery and id-based runs Prevent tests IDs from drifting between pytest discovery and running Sep 17, 2026
@C-Achard C-Achard added the 3.1 label Sep 17, 2026
@C-Achard C-Achard added 3.0.3 and removed 3.1 labels Oct 21, 2026

@deruyter92 deruyter92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful!

One minor comment, otherwise LGTM!

@deruyter92
deruyter92 merged commit bdacd8a into dev Oct 22, 2026
4 of 5 checks passed
@deruyter92
deruyter92 deleted the cy/fix-random-test-init branch October 22, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0.3 enhancement New feature or request tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants