-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] Ensure datetime.time can be serialized to JSON #10795
Conversation
✅ Deploy Preview for niobium-lead-7998 canceled.
|
for more information, see https://pre-commit.ci
❌ 180 Tests Failed:
View the top 3 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
tests/test_ge_utils.py
Outdated
|
||
|
||
@pytest.mark.unit | ||
@pytest.mark.parametrize( | ||
"data", [pytest.param({"t": datetime.time(hour=1, minute=30, second=45)}, id="datetime.time")] | ||
) | ||
def test_convert_to_json_serializable_converts_correctly(data: dict): | ||
ret = convert_to_json_serializable(data) | ||
assert ret == {"t": "01:30:45"} | ||
|
||
|
||
@pytest.mark.unit | ||
@pytest.mark.parametrize( | ||
"data", [pytest.param({"t": datetime.time(hour=1, minute=30, second=45)}, id="datetime.time")] | ||
) | ||
def test_ensure_json_serializable(data: dict): | ||
ensure_json_serializable(data) | ||
# Passes if no exception raised |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests look good, but they should probably live in tests.test_convert_to_json_serializable
, unless there's a compelling reason to break the pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll move. I didn't notice that file assuming we were following the pattern of test file per module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that would be super reasonable - at some point we could refactor this to be more logical. thanks for addressing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just would recommend writing these tests next to the ones we already ahve
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Adds
datetime.time
handling to the serialization code in utils.datetime.time
is now serializable, and serialization is performed by converting it to its ISO format string.invoke lint
(usesruff format
+ruff check
)For more information about contributing, visit our community resources.
After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!