fix(tests): test_auto_calibration_in_quiet_window fails when test_occupancy.py runs first #221

Closed
opened 2026-10-02 23:51:49 +00:00 by gabogg · 0 comments
Owner

Agent Brief

Category: bug
Summary: tests/test_calibration_reconciliation.py::test_auto_calibration_in_quiet_window fails whenever tests/test_occupancy.py runs before it. The test depends on run order.

Current behavior:

  • Found during the #168 third review pass (2026-10-02).
  • Running the two files together, with test_occupancy.py first, fails test_auto_calibration_in_quiet_window. It passes on its own and in the default full-suite order.
  • The same pair fails the same way on a copy of master, so #168 didn't cause it.
  • The likely cause is state leaking from test_occupancy.py: monitor or service singletons, cached config, the active multiplier, or the calibration window and clock.

Desired behavior:

  • The test passes in any order, alone, after test_occupancy.py, and under random ordering.
  • Whatever leaks is either reset by a fixture, or no longer kept in module or singleton state between tests.

Acceptance criteria:

  • pytest tests/test_occupancy.py tests/test_calibration_reconciliation.py passes.
  • The reverse order passes too, as does the full suite.
  • The leaked state is identified in the PR, and the fix resets it at its source, not with a workaround in this one test.
  • If #217 or #218 adds parallel or random-order runs, this test passes under them.

Out of scope:

  • Other order-dependence not shown by this pair. Note any found in the PR.

Refs #168, #217, #218.

🤖 Generated with Claude Code

## Agent Brief **Category:** bug **Summary:** `tests/test_calibration_reconciliation.py::test_auto_calibration_in_quiet_window` fails whenever `tests/test_occupancy.py` runs before it. The test depends on run order. **Current behavior:** - Found during the #168 third review pass (2026-10-02). - Running the two files together, with `test_occupancy.py` first, fails `test_auto_calibration_in_quiet_window`. It passes on its own and in the default full-suite order. - The same pair fails the same way on a copy of master, so #168 didn't cause it. - The likely cause is state leaking from `test_occupancy.py`: monitor or service singletons, cached config, the active multiplier, or the calibration window and clock. **Desired behavior:** - The test passes in any order, alone, after `test_occupancy.py`, and under random ordering. - Whatever leaks is either reset by a fixture, or no longer kept in module or singleton state between tests. **Acceptance criteria:** - [ ] `pytest tests/test_occupancy.py tests/test_calibration_reconciliation.py` passes. - [ ] The reverse order passes too, as does the full suite. - [ ] The leaked state is identified in the PR, and the fix resets it at its source, not with a workaround in this one test. - [ ] If #217 or #218 adds parallel or random-order runs, this test passes under them. **Out of scope:** - Other order-dependence not shown by this pair. Note any found in the PR. Refs #168, #217, #218. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#221
No description provided.