Skip to content
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

Tests: Use UTC-based utcnow().date() instead of localtime-based date.today() #441

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/crate/client/sqlalchemy/doctests/itests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ aren't set when the row is inserted as there is no default method::

The datetime and date can be set using a update statement::

>>> location.nullable_date = datetime.today()
>>> location.nullable_date = datetime.utcnow().date()
>>> location.nullable_datetime = datetime.utcnow()
>>> session.flush()

Expand Down
4 changes: 2 additions & 2 deletions src/crate/client/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import unittest
import doctest
from pprint import pprint
from datetime import datetime, date
from datetime import datetime
from http.server import HTTPServer, BaseHTTPRequestHandler
import ssl
import time
Expand Down Expand Up @@ -213,7 +213,7 @@ class Location(Base):
__tablename__ = 'locations'
name = sa.Column(sa.String, primary_key=True)
kind = sa.Column(sa.String)
date = sa.Column(sa.Date, default=date.today)
date = sa.Column(sa.Date, default=lambda: datetime.utcnow().date())
datetime_tz = sa.Column(sa.DateTime, default=datetime.utcnow)
datetime_notz = sa.Column(sa.DateTime, default=datetime.utcnow)
nullable_datetime = sa.Column(sa.DateTime)
Expand Down