mikebridge opened a new pull request, #44260: URL: https://github.com/apache/superset/pull/44260
### SUMMARY `TestTagApi::test_get_tag` is a recurring CI flake: it asserts `changed_on_delta_humanized == "now"` under `freeze_time(datetime.now())` and intermittently fails with `assert 'now' == 'a second from now'` (four re-triggers across unrelated PRs in one day). **Root cause.** The frozen clock never reaches the stored timestamp. `AuditMixinNullable` declares `created_on` / `changed_on` with `default=datetime.now` (`superset/models/helpers.py:1258-1260`), which captures the *real* `datetime.now` bound method at import time; freezegun rebinds the `datetime` class on loaded modules but cannot rebind a method object stored inside SQLAlchemy's `ColumnDefault`. `format_time_humanized` (`helpers.py:1233`), on the other hand, looks up `datetime.now()` at call time and gets the frozen clock. So the stamp is from the real clock, later than the frozen instant, and whenever the two straddle a second boundary `humanize` renders "a second from now". **Fix (test only).** Freeze at a fixed instant and stamp `created_on` / `changed_on` explicitly from the frozen clock before the first flush (an explicit value wins over the column default), so the humanized delta is exactly zero on every run. The assertion stays exact — no widening, no sleeps. **Evidence.** Reproduced deterministically by freezing one second behind the real clock → `'a second from now'`; control: freezing in 2024 *without* the explicit stamps → `'2 years from now'` (the stamp demonstrably comes from the real clock). No sibling test in the file asserts a humanized value. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A (test-only). ### TESTING INSTRUCTIONS ``` pytest tests/integration_tests/tags/api_tests.py -k test_get_tag ``` Run it in a loop; it no longer depends on where the wall clock is within a second. Full file: 27 passed on PostgreSQL; on SQLite the only failure is the pre-existing `test_post_bulk_tag_skipped_tags_perm` (fails identically on `master` in the same environment). ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
