26
26
from sqlalchemy import and_
27
27
28
28
import sqlalchemy .testing .suite .test_types
29
+ import sqlalchemy .sql .sqltypes
29
30
from sqlalchemy .testing import util
30
31
from sqlalchemy .testing .assertions import eq_
31
32
from sqlalchemy .testing .suite import config , select , exists
@@ -62,13 +63,26 @@ def test_literal(self):
62
63
63
64
def literal (value ):
64
65
assert value == self .data
65
- import sqlalchemy .sql .sqltypes
66
-
67
66
return sqlalchemy .sql .elements .literal (value , self .datatype )
68
67
69
68
with mock .patch ("sqlalchemy.testing.suite.test_types.literal" , literal ):
70
69
super (TimestampMicrosecondsTest , self ).test_literal ()
71
70
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
+
72
86
else :
73
87
from sqlalchemy .testing .suite import (
74
88
FetchLimitOffsetTest as _FetchLimitOffsetTest ,
@@ -109,7 +123,6 @@ def test_limit_render_multiple_times(self, connection):
109
123
del PostCompileParamsTest
110
124
111
125
class TimestampMicrosecondsTest (_TimestampMicrosecondsTest ):
112
-
113
126
data = datetime .datetime (2012 , 10 , 15 , 12 , 57 , 18 , 396 , tzinfo = pytz .UTC )
114
127
115
128
def test_literal (self , literal_round_trip ):
@@ -118,6 +131,21 @@ def test_literal(self, literal_round_trip):
118
131
119
132
def literal (value , type_ = None ):
120
133
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
+
121
149
if type_ is not None :
122
150
assert type_ is self .datatype
123
151
@@ -126,7 +154,7 @@ def literal(value, type_=None):
126
154
return sqlalchemy .sql .elements .literal (value , self .datatype )
127
155
128
156
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 )
130
158
131
159
def test_round_trip_executemany (self , connection ):
132
160
unicode_table = self .tables .unicode_table
0 commit comments