Skip to content

Commit a050ccf

Browse files
authored
fix: updates test to account for UTC in failing test (googleapis#501)
* Sets cache support to false, removes upper req limit * fix: adds timestamp to ensure tests pass successfully * fix: updates tests to account for UTC * restores path in nox session
1 parent be63adc commit a050ccf

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from sqlalchemy import and_
2727

2828
import sqlalchemy.testing.suite.test_types
29+
import sqlalchemy.sql.sqltypes
2930
from sqlalchemy.testing import util
3031
from sqlalchemy.testing.assertions import eq_
3132
from sqlalchemy.testing.suite import config, select, exists
@@ -62,13 +63,26 @@ def test_literal(self):
6263

6364
def literal(value):
6465
assert value == self.data
65-
import sqlalchemy.sql.sqltypes
66-
6766
return sqlalchemy.sql.elements.literal(value, self.datatype)
6867

6968
with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
7069
super(TimestampMicrosecondsTest, self).test_literal()
7170

71+
def test_select_direct(self, connection):
72+
# This func added because this test was failing when passed the
73+
# UTC timezone.
74+
75+
def literal(value, type_=None):
76+
assert value == self.data
77+
78+
if type_ is not None:
79+
assert type_ is self.datatype
80+
81+
return sqlalchemy.sql.elements.literal(value, self.datatype)
82+
83+
with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
84+
super(TimestampMicrosecondsTest, self).test_select_direct(connection)
85+
7286
else:
7387
from sqlalchemy.testing.suite import (
7488
FetchLimitOffsetTest as _FetchLimitOffsetTest,
@@ -109,7 +123,6 @@ def test_limit_render_multiple_times(self, connection):
109123
del PostCompileParamsTest
110124

111125
class TimestampMicrosecondsTest(_TimestampMicrosecondsTest):
112-
113126
data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396, tzinfo=pytz.UTC)
114127

115128
def test_literal(self, literal_round_trip):
@@ -118,6 +131,21 @@ def test_literal(self, literal_round_trip):
118131

119132
def literal(value, type_=None):
120133
assert value == self.data
134+
if type_ is not None:
135+
assert type_ is self.datatype
136+
137+
return sqlalchemy.sql.elements.literal(value, self.datatype)
138+
139+
with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
140+
super(TimestampMicrosecondsTest, self).test_literal(literal_round_trip)
141+
142+
def test_select_direct(self, connection):
143+
# This func added because this test was failing when passed the
144+
# UTC timezone.
145+
146+
def literal(value, type_=None):
147+
assert value == self.data
148+
121149
if type_ is not None:
122150
assert type_ is self.datatype
123151

@@ -126,7 +154,7 @@ def literal(value, type_=None):
126154
return sqlalchemy.sql.elements.literal(value, self.datatype)
127155

128156
with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
129-
super(TimestampMicrosecondsTest, self).test_literal(literal_round_trip)
157+
super(TimestampMicrosecondsTest, self).test_select_direct(connection)
130158

131159
def test_round_trip_executemany(self, connection):
132160
unicode_table = self.tables.unicode_table

0 commit comments

Comments
 (0)