mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-11-25 15:06:20 +01:00
Slow tests: - TestPerformance inserted 10 000 records three times per backend. One test per backend now times insert, save and load on the same records, with the same assertions. - test_measurement_realtime_stream slept one second per update, 20 s per backend. The updates use synthetic timestamps one second apart in the recent past, without a pause, and send the same duplicates, out-of-order and burst writes. - test_readers_never_see_a_partial_document: the readers spun on the cache and kept the writer waiting for the GIL (~50 s). They now yield with time.sleep(0) after each lookup (~0.5 s); a non-atomic save still fails the test 10 of 10 times. - test_devicessettingsbattery.py compiled the same plain profile before each of its 235 tests. A module-scoped fixture compiles it once; a compiled profile is frozen and may be shared (20.8 s -> 9.4 s). - The --finalize case of test_geneticoptimize.py runs 250 instead of 400 generations. For this input and seed the best fitness is final in generation 213, and the solutions after 250 and 400 generations are identical field by field. The test checks the keys and the consistency of the result, not the schedule, so it detects the same as before (127 s -> 80 s on GitHub runners). test_genetic0optimize.py keeps 400. Tests that depended on another test of the same process, found by running them in another order and under pytest-xdist: - TestPredictionContainer::test_len relied on a class flag that a TestPredictionProvider fixture set and never reset. Both fixtures now set the flags with monkeypatch. - The EnergyCharts status code test got a cached response from an earlier test; it now calls _request_forecast(force_update=True) and asserts that the request was made. - test_ingress_safe_links did not wait for EOSdash, which EOS starts after its own startup. - test_forward_stream_truncates_very_long_line found the log queue left behind by test_server_start_eosdash (no worker, closed event loop). It installs its own queue now, and test_server_start_eosdash no longer leaves its queue behind. Dropping lines from a full queue was only covered through that left-over queue and gets a test of its own. Refs #1553 Co-authored-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com> Assisted-by: Claude Code (claude-opus-5-5) Assisted-by: Claude Code (claude-fable-5-2)
35 lines
1.3 KiB
Markdown
35 lines
1.3 KiB
Markdown
---
|
|
name: testing
|
|
description: Use when adding or updating pytest tests, fixing bugs, or changing behavior that needs test coverage.
|
|
---
|
|
|
|
# Testing
|
|
|
|
## When to use
|
|
|
|
- Any behavior change or bug fix.
|
|
|
|
## Rules
|
|
|
|
- **Prefer adding tests to existing test classes in existing test modules.**
|
|
Extend the relevant class/module rather than creating new files.
|
|
- Create a new test module only when:
|
|
- functionality is a distinct aspect that does not fit any existing module, or
|
|
- it targets a different component/test target.
|
|
- Follow existing conventions, fixtures, and markers.
|
|
- Prefer deterministic, isolated tests; mock external services/devices.
|
|
- Cover boundary conditions and error paths.
|
|
- Do not weaken tests to accommodate implementation defects.
|
|
- Keep each test case well under a second. No real-time sleeps or wait loops
|
|
(use synthetic timestamps), no full cartesian `parametrize` over independent
|
|
axes, and extend an existing parametrized test before writing a new one.
|
|
The CI log lists the 25 slowest tests (`--durations=25`).
|
|
|
|
## Verify
|
|
|
|
- Run the relevant pytest tests and checks with the project's configured
|
|
commands and environment before declaring the change complete.
|
|
- Run a full test run:
|
|
- Only one run at a time. Stop any running full test run before start of a new.
|
|
- Run the equivalent of make gen-docs before a full run.
|