Skip to content

test_project_screen reads the clock twice, so «Экземпляр жив» shows 11 minutes on Linux and fails CI #361

Closed

Description

@lumenpearson

server/tests/test_project_screen.py::test_the_screen_shows_each_block (the monitoring branch, #359, written in 749fd6d) fails on every CI run and passes on the owner's Windows machine.

The test takes now = _now() and passes it to the helper _stats(now=now, …). The helper reads the clock a second time for its own now, builds started_at as that second reading minus twelve minutes, and only then lets the test's now override its own. So the instance has lived twelve minutes less the gap between the two readings, and project_render._minutes rounds down: «Экземпляр жив: 11 мин», where the test asks for 12.

Failure scenario: on Linux consecutive datetime.now() calls differ by microseconds, so the gap is never zero and the test fails every time — CI's «Server (API + bot)» on 4cb751a (15:20 UTC, 6 October 2026: 1 failed, 2706 passed) and on 4b0cd19 (16:34 UTC: 1 failed, 2711 passed). On Windows 99,957 of 99,999 consecutive readings were equal on this machine, so the local full runs (2707 and 2712 passed) never saw it. With _now replaced by a clock that advances one microsecond per call, the test fails locally too, alone in its file.

The renderer is right: it counts whole minutes from the instance's start, and a process that has lived 11 min 59.99 s has lived eleven. The defect is the test's helper reading the clock twice. It blocks #359's merge, because CI is red on its head.

Fix, in #359 before it merges: _stats builds started_at from the now it is given, when it is given one, so one test reads one clock. Found by reading CI's log after the push of 4b0cd19.

Activity

  1. added this to lessons and removed this from lessonson Oct 6, 2026
  2. moved this to In progress in lessonson Oct 6, 2026
  3. added 2 commits that reference this issue on Oct 6, 2026
    5052df1
    6b9b58c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions