- test_types, test_compiler, with sqlite at least

This commit is contained in:
Mike Bayer
2013-04-28 14:44:21 -04:00
parent 18370ac032
commit fc624dcfa4
5 changed files with 43 additions and 68 deletions
+2 -1
View File
@@ -734,13 +734,14 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
'JOIN myothertable ON mytable.myid = '
'myothertable.otherid')
def test_label_comparison(self):
def test_label_comparison_one(self):
x = func.lala(table1.c.myid).label('foo')
self.assert_compile(select([x], x == 5),
'SELECT lala(mytable.myid) AS foo FROM '
'mytable WHERE lala(mytable.myid) = '
':param_1')
def test_label_comparison_two(self):
self.assert_compile(
label('bar', column('foo', type_=String)) + 'foo',
'foo || :param_1')
+23 -47
View File
@@ -141,24 +141,14 @@ class AdaptTest(fixtures.TestBase):
eq_(types.Integer().python_type, int)
eq_(types.Numeric().python_type, decimal.Decimal)
eq_(types.Numeric(asdecimal=False).python_type, float)
# start Py3K
eq_(types.LargeBinary().python_type, bytes)
# end Py3K
# start Py2K
# eq_(types.LargeBinary().python_type, str)
# end Py2K
eq_(types.LargeBinary().python_type, util.binary_type)
eq_(types.Float().python_type, float)
eq_(types.Interval().python_type, datetime.timedelta)
eq_(types.Date().python_type, datetime.date)
eq_(types.DateTime().python_type, datetime.datetime)
# start Py3K
eq_(types.String().python_type, str)
# end Py3K
# start Py2K
# eq_(types.String().python_type, str)
# end Py2K
eq_(types.Unicode().python_type, str)
eq_(types.String(convert_unicode=True).python_type, str)
eq_(types.Unicode().python_type, util.text_type)
eq_(types.String(convert_unicode=True).python_type, util.text_type)
assert_raises(
NotImplementedError,
@@ -259,14 +249,14 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL):
def test_processing(self):
users = self.tables.users
users.insert().execute(
user_id=2, goofy='jack', goofy2='jack', goofy4='jack',
goofy7='jack', goofy8=12, goofy9=12)
user_id=2, goofy='jack', goofy2='jack', goofy4=util.u('jack'),
goofy7=util.u('jack'), goofy8=12, goofy9=12)
users.insert().execute(
user_id=3, goofy='lala', goofy2='lala', goofy4='lala',
goofy7='lala', goofy8=15, goofy9=15)
user_id=3, goofy='lala', goofy2='lala', goofy4=util.u('lala'),
goofy7=util.u('lala'), goofy8=15, goofy9=15)
users.insert().execute(
user_id=4, goofy='fred', goofy2='fred', goofy4='fred',
goofy7='fred', goofy8=9, goofy9=9)
user_id=4, goofy='fred', goofy2='fred', goofy4=util.u('fred'),
goofy7=util.u('fred'), goofy8=9, goofy9=9)
l = users.select().order_by(users.c.user_id).execute().fetchall()
for assertstr, assertint, assertint2, row in zip(
@@ -280,7 +270,7 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL):
eq_(row[5], assertint)
eq_(row[6], assertint2)
for col in row[3], row[4]:
assert isinstance(col, str)
assert isinstance(col, util.text_type)
def test_typedecorator_impl(self):
for impl_, exp, kw in [
@@ -717,9 +707,9 @@ class UnicodeTest(fixtures.TestBase):
expected
)
data = "Alors vous imaginez ma surprise, au lever du jour, quand "\
data = util.u("Alors vous imaginez ma surprise, au lever du jour, quand "\
"une drôle de petite voix ma réveillé. "\
"Elle disait: « Sil vous plaît… dessine-moi un mouton! »"
"Elle disait: « Sil vous plaît… dessine-moi un mouton! »")
def test_unicode_warnings_typelevel_native_unicode(self):
@@ -728,14 +718,12 @@ class UnicodeTest(fixtures.TestBase):
dialect = default.DefaultDialect()
dialect.supports_unicode_binds = True
uni = u.dialect_impl(dialect).bind_processor(dialect)
# start Py3K
assert_raises(exc.SAWarning, uni, b'x')
assert isinstance(uni(unicodedata), str)
# end Py3K
# start Py2K
# assert_raises(exc.SAWarning, uni, 'x')
# assert isinstance(uni(unicodedata), unicode)
# end Py2K
if util.py3k:
assert_raises(exc.SAWarning, uni, b'x')
assert isinstance(uni(unicodedata), str)
else:
assert_raises(exc.SAWarning, uni, 'x')
assert isinstance(uni(unicodedata), unicode)
def test_unicode_warnings_typelevel_sqla_unicode(self):
unicodedata = self.data
@@ -743,14 +731,8 @@ class UnicodeTest(fixtures.TestBase):
dialect = default.DefaultDialect()
dialect.supports_unicode_binds = False
uni = u.dialect_impl(dialect).bind_processor(dialect)
# start Py3K
assert_raises(exc.SAWarning, uni, b'x')
assert isinstance(uni(unicodedata), bytes)
# end Py3K
# start Py2K
# assert_raises(exc.SAWarning, uni, 'x')
# assert isinstance(uni(unicodedata), str)
# end Py2K
assert_raises(exc.SAWarning, uni, util.b('x'))
assert isinstance(uni(unicodedata), util.binary_type)
eq_(uni(unicodedata), unicodedata.encode('utf-8'))
@@ -763,15 +745,9 @@ class UnicodeTest(fixtures.TestBase):
s = String()
uni = s.dialect_impl(dialect).bind_processor(dialect)
# this is not the unicode type - no warning
# start Py3K
uni(b'x')
assert isinstance(uni(unicodedata), bytes)
# end Py3K
# start Py2K
# uni('x')
# assert isinstance(uni(unicodedata), str)
# end Py2K
uni(util.b('x'))
assert isinstance(uni(unicodedata), util.binary_type)
eq_(uni(unicodedata), unicodedata.encode('utf-8'))