test: fix test by comparing timezone-aware timestamps#39782
Conversation
Code Review Agent Run #0014a6Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
c097733 to
6e2720b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #39782 +/- ##
==========================================
- Coverage 64.16% 64.16% -0.01%
==========================================
Files 2590 2590
Lines 138087 138090 +3
Branches 32039 32040 +1
==========================================
Hits 88609 88609
- Misses 47953 47956 +3
Partials 1525 1525
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
801d31c to
992e9b0
Compare
992e9b0 to
ec790df
Compare
Code Review Agent Run #8e8ef1Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Hey @hy144328, nice catch — timezone issues in tests are always annoying 😅 This looks like a good fix, making the test independent of the environment makes a lot of sense. Just wondering — are both timestamps being compared in the same timezone explicitly, or does it rely on how Python handles it internally? Also might be worth adding a quick comment in the test about why this is needed, just so it’s clearer for anyone reading it later. Overall looks solid. |
|
@Mayankaggarwal8055 Thanks for the feedback, and sorry for the late reply!
Good point.
It relies on how Python implicitly handles timezone-naive timestamps. |
Code Review Agent Run #24174Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Got it, that makes sense — thanks for the clarification! The explanation about how Python handles timezone-naive vs aware timestamps really helps. The added comment in the test should definitely make this clearer for future readers. Happy to see this getting addressed 👍 |
|
Running CI 🤞 Noting that #40034 tackles this implementation as well... taking a look at that too. |
|
This fix makes the test environment-independent, but it does so by changing the nature of the test input — the datetimes are no longer naive. The production code path being tested (dttm.timestamp() on a naive datetime) is what actually runs in the real application, because the callers throughout the Superset codebase pass naive datetimes. So the test is now no longer testing the real code path — it's testing a scenario that doesn't happen in practice (a timezone-aware input), and the underlying bug in the implementation (where a naive datetime produces a timezone-dependent epoch) remains live and unfixed. The best aproach would be to combine elements of both...
|
|
Thanks for the explanation @rusackas — that clears it up a lot. I didn’t think about the fact that the updated test was no longer covering the actual production path with naive datetimes. Keeping the test behavior aligned with real usage definitely makes more sense here. Combining both approaches sounds like the best fix:
I also noticed the failing Been enjoying following these timezone and dashboard issues lately — there are a lot of subtle edge cases in Superset. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes flaky unit tests that depended on the host environment’s local timezone by making the test datetimes explicitly timezone-aware (UTC) so they compare correctly against epoch-based expected values.
Changes:
- Import
timezoneand usetimezone.utcon test datetimes used for epoch formatting assertions - Add clarifying comments explaining timezone-naive vs timezone-aware expectations in the parametrized test data
a56bf63 to
14ea0eb
Compare
@rusackas Thank you for the clarification. As suggested, I have reverted my own changes to the unit test, and applied @charliesheh 's ideas from #40034 . |
bac86f2 to
9dcf023
Compare
|
/review |
9dcf023 to
9eb7e03
Compare
There was a problem hiding this comment.
Code Review Agent Run #354d9b
Actionable Suggestions - 1
-
superset/models/helpers.py - 1
- Assert statement used in production code · Line 2401-2401
Review Details
-
Files reviewed - 1 · Commit Range:
52fa7f3..9dcf023- superset/models/helpers.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
|
/review |
Code Review Agent Run #ad8868Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #319287Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Fixes #39781 .
SUMMARY
Currently, two testcases rely on the environment to have UTC timezone in order to pass.
The problem is that given timestamp is timezone-native, and that the solution timestamp is a UNIX timestamp, and thus timezone-aware.
Fix the timezone for those timestamps.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
This test passes here but not on the main branch:
ADDITIONAL INFORMATION