Skip to content

test(logging): stop the location assertion matching the clock - #496

Merged
ChuckBuilds merged 1 commit into
mainfrom
test/fix-flaky-location-assertion
Aug 23, 2026
Merged

test(logging): stop the location assertion matching the clock#496
ChuckBuilds merged 1 commit into
mainfrom
test/fix-flaky-location-assertion

Conversation

@ChuckBuilds

Copy link
Copy Markdown
Owner

Found by a full-suite run that went red on a file I hadn't touched:

E   AssertionError: assert ':42' not in '2026-08-22 08:05:42.274 - INFO - test.logger - hello'
E     ':42' is contained here:
E       2026-08-22 08:05:42.274 - INFO - test.logger - hello

test_location_toggle checks that location info is absent when include_location=False. It does that by asserting the substring f":{record.lineno}" is missing — and make_record() hardcodes lineno=42.

Every formatted line begins with an HH:MM:SS.mmm timestamp, so ":42" also matches the clock. The test fails whenever the minute or the second happens to be 42 — about 3% of runs, at a time of day nobody can reproduce on request.

The fix

Assert on the whole token the format string actually emits:

fmt = '... - %(module)s.%(funcName)s:%(lineno)d - %(message)s'

so the assertion becomes f"{record.module}.{record.funcName}:{record.lineno}". That can't collide with a timestamp, and it checks the thing the test is named for rather than a fragment of it.

Verification

Formatted a record stamped 08:42:42 — minute and second colliding:

formatted: 2026-08-22 08:42:42.043 - INFO - test.logger - hello
old assertion ':42' not in line    -> False   (the flake)
new assertion location not in line -> True    (fixed)

test/test_logging_config.py passes; full suite unaffected.

Worth noting because it is the second time this suite has produced a failure that looks like a real regression and isn't — the other being test_install_lowmem.py's tmpfs assumption (#492). Both cost more to diagnose than to fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW

test_location_toggle asserted that ":42" -- a bare colon plus the record's
hardcoded lineno -- is absent from a line formatted with include_location=False.
But every formatted line starts with an HH:MM:SS.mmm timestamp, so ":42" also
matches the clock whenever the minute or the second is 42. The test fails for
roughly 3% of runs with nothing wrong:

  2026-08-22 08:05:42.274 - INFO - test.logger - hello
                     ^^^ matches ":42"

Assert on the whole "module.funcName:lineno" token the format string actually
emits ('%(module)s.%(funcName)s:%(lineno)d') instead of a fragment of it. That
cannot collide with a timestamp, and it checks the thing the test is named for.

Confirmed by formatting a record stamped 08:42:42 -- both minute and second
colliding: the old assertion fails, the new one passes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@ChuckBuilds, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b8b3bd6b-83b9-48b9-bd12-551b267ca562

📥 Commits

Reviewing files that changed from the base of the PR and between 6b74506 and a997e75.

📒 Files selected for processing (1)
  • test/test_logging_config.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ChuckBuilds
ChuckBuilds merged commit 085fb93 into main Aug 23, 2026
9 checks passed
@ChuckBuilds
ChuckBuilds deleted the test/fix-flaky-location-assertion branch August 23, 2026 15:44
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