Skip to content

Make the writer datetime test independent of local timezone - #32

Open
saitakarcesme wants to merge 1 commit into
python-lsp:developfrom
saitakarcesme:codex/timezone-independent-writer-test
Open

saitakarcesme wants to merge 1 commit into
python-lsp:developfrom
saitakarcesme:codex/timezone-independent-writer-test

Conversation

@saitakarcesme

Copy link
Copy Markdown

Fixes #6. test_writer_bad_message calls timestamp() on a naive datetime, so its expected bytes depend on the host timezone. The two hard-coded timestamps only cover some environments; adding another timestamp as in the closed #7 would leave the underlying problem.

Use a UTC-aware JsonDatetime and keep a single timestamp expectation (1546304461), while retaining the existing empty-output allowance for the standard JSON fallback. Instantiate the subclass directly instead of permanently replacing the global datetime.datetime class.

Validation on Python 3.13.5:

  • Before the change, the test passes in UTC and America/New_York but fails in Europe/Luxembourg, Asia/Kathmandu and Pacific/Chatham.
  • After the change, all 27 tests pass in each of those five timezones with both ujson 6.0.0 and the standard-library JSON fallback (10 separate processes). Also verified datetime.datetime retains its original identity after each suite run.
  • Repository-wide pylint (10.00/10), pycodestyle, pyflakes and git diff --check pass.

This is a test-only change; it does not alter production serialization or the separate orjson migration in #29. No Windows/OpenBSD run was performed locally.

AI disclosure: prepared and tested by OpenAI Codex acting on behalf of @saitakarcesme. No independent human review is claimed.

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.

Test test_writer_bad_message fails with ujson

1 participant