Skip to content

Commit

Permalink
fix: updates test to account for UTC in failing test (#501)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chalmerlowe authored Nov 10, 2022
1 parent be63adc commit a050ccf
Showing 1 changed file with 32 additions and 4 deletions.
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

0 comments on commit a050ccf

Please sign in to comment.