Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
36 changes: 32 additions & 4 deletions tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from sqlalchemy import and_

import sqlalchemy.testing.suite.test_types
import sqlalchemy.sql.sqltypes
from sqlalchemy.testing import util
from sqlalchemy.testing.assertions import eq_
from sqlalchemy.testing.suite import config, select, exists
Expand Down Expand Up @@ -62,13 +63,26 @@ def test_literal(self):

def literal(value):
assert value == self.data
import sqlalchemy.sql.sqltypes

return sqlalchemy.sql.elements.literal(value, self.datatype)

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

def test_select_direct(self, connection):
# This func added because this test was failing when passed the
# UTC timezone.

def literal(value, type_=None):
assert value == self.data

if type_ is not None:
assert type_ is self.datatype

return sqlalchemy.sql.elements.literal(value, self.datatype)

with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
super(TimestampMicrosecondsTest, self).test_select_direct(connection)

else:
from sqlalchemy.testing.suite import (
FetchLimitOffsetTest as _FetchLimitOffsetTest,
Expand Down Expand Up @@ -109,7 +123,6 @@ def test_limit_render_multiple_times(self, connection):
del PostCompileParamsTest

class TimestampMicrosecondsTest(_TimestampMicrosecondsTest):

data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396, tzinfo=pytz.UTC)

def test_literal(self, literal_round_trip):
Expand All @@ -118,6 +131,21 @@ def test_literal(self, literal_round_trip):

def literal(value, type_=None):
assert value == self.data
if type_ is not None:
assert type_ is self.datatype

return sqlalchemy.sql.elements.literal(value, self.datatype)

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

def test_select_direct(self, connection):
# This func added because this test was failing when passed the
# UTC timezone.

def literal(value, type_=None):
assert value == self.data

if type_ is not None:
assert type_ is self.datatype

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

with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
super(TimestampMicrosecondsTest, self).test_literal(literal_round_trip)
super(TimestampMicrosecondsTest, self).test_select_direct(connection)

def test_round_trip_executemany(self, connection):
unicode_table = self.tables.unicode_table
Expand Down