From 82ea44781985ce608185370a648db729de2cc2d9 Mon Sep 17 00:00:00 2001 From: Taavi Burns Date: Mon, 14 Mar 2011 14:42:11 -0400 Subject: [PATCH] Tests for unicode columns with non-unicode defaults. See #2079. --- test/sql/test_defaults.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index 617a29edad..eeb4ebbcb8 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -5,7 +5,7 @@ from sqlalchemy.sql import select, text, literal_column import sqlalchemy as sa from test.lib import testing, engines from sqlalchemy import MetaData, Integer, String, ForeignKey, Boolean, exc,\ - Sequence, func, literal + Sequence, func, literal, Unicode from sqlalchemy.types import TypeDecorator from test.lib.schema import Table, Column from test.lib.testing import eq_ @@ -934,3 +934,29 @@ class ServerDefaultsOnPKTest(testing.TestBase): [(5, 'data')] ) +class UnicodeDefaultsTest(testing.TestBase): + def test_no_default(self): + c = Column(Unicode(32)) + + def test_unicode_default(self): + # Py3K + #default = 'foo' + # Py2K + default = u'foo' + # end Py2K + c = Column(Unicode(32), default=default) + + + def test_nonunicode_default(self): + # Py3K + #default = b'foo' + # Py2K + default = 'foo' + # end Py2K + assert_raises_message( + sa.exc.SAWarning, + "Unicode column received non-unicode default value.", + Column, + Unicode(32), + default=default + ) -- 2.47.3