for row in rows:
assert isinstance(row[0], util.text_type)
+ def _test_null_strings(self, connection):
+ unicode_table = self.tables.unicode_table
+
+ connection.execute(unicode_table.insert(), {"unicode_data": None})
+ row = connection.execute(
+ select([unicode_table.c.unicode_data])
+ ).first()
+ eq_(row, (None,))
+
def _test_empty_strings(self, connection):
unicode_table = self.tables.unicode_table
def test_empty_strings_varchar(self, connection):
self._test_empty_strings(connection)
+ def test_null_strings_varchar(self, connection):
+ self._test_null_strings(connection)
+
class UnicodeTextTest(_UnicodeFixture, fixtures.TablesTest):
__requires__ = "unicode_data", "text_type"
def test_empty_strings_text(self, connection):
self._test_empty_strings(connection)
+ def test_null_strings_text(self, connection):
+ self._test_null_strings(connection)
+
class TextTest(_LiteralRoundTripFixture, fixtures.TablesTest):
__requires__ = ("text_type",)
row = connection.execute(select([text_table.c.text_data])).first()
eq_(row, ("some text",))
+ @testing.requires.empty_strings_text
def test_text_empty_strings(self, connection):
text_table = self.tables.text_table
row = connection.execute(select([text_table.c.text_data])).first()
eq_(row, ("",))
+ def test_text_null_strings(self, connection):
+ text_table = self.tables.text_table
+
+ connection.execute(text_table.insert(), {"text_data": None})
+ row = connection.execute(select([text_table.c.text_data])).first()
+ eq_(row, (None,))
+
def test_literal(self):
self._literal_round_trip(Text, ["some text"], ["some text"])
)
_oracle_char_combinations = testing.combinations(
- ("STRING", cx_Oracle_STRING, False),
- ("FIXED_CHAR", cx_Oracle_FIXED_CHAR, False),
- ("CLOB", cx_Oracle_CLOB, True),
- ("NCLOB", cx_Oracle_NCLOB, True),
- argnames="cx_oracle_type,use_read",
- id_="iaa",
+ ("STRING", cx_Oracle_STRING,),
+ ("FIXED_CHAR", cx_Oracle_FIXED_CHAR,),
+ ("CLOB", cx_Oracle_CLOB,),
+ ("NCLOB", cx_Oracle_NCLOB,),
+ argnames="cx_oracle_type",
+ id_="ia",
)
- def _assert_errorhandler(self, outconverter, use_read, has_errorhandler):
+ def _assert_errorhandler(self, outconverter, has_errorhandler):
data = ue("\uee2c\u9a66") # this is u"\uee2c\u9a66"
utf8_w_errors = data.encode("utf-16")
- if use_read:
- utf8_w_errors = mock.Mock(
- read=mock.Mock(return_value=utf8_w_errors)
- )
-
if has_errorhandler:
eq_(
@_oracle_char_combinations
@testing.requires.python3
- def test_older_cx_oracle_warning(
- self, cx_Oracle, cx_oracle_type, use_read
- ):
+ def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type):
cx_Oracle.version = "6.3"
ignore_dialect = cx_oracle.dialect(
@_oracle_char_combinations
@testing.requires.python2
def test_encoding_errors_sqla_py2k(
- self, cx_Oracle, cx_oracle_type, use_read
+ self, cx_Oracle, cx_oracle_type,
):
ignore_dialect = cx_oracle.dialect(
dbapi=cx_Oracle, encoding_errors="ignore"
cursor = mock.Mock()
ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
outconverter = cursor.mock_calls[0][2]["outconverter"]
- self._assert_errorhandler(outconverter, use_read, True)
+ self._assert_errorhandler(outconverter, True)
@_oracle_char_combinations
@testing.requires.python2
def test_no_encoding_errors_sqla_py2k(
- self, cx_Oracle, cx_oracle_type, use_read
+ self, cx_Oracle, cx_oracle_type,
):
plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle)
cursor = mock.Mock()
plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
outconverter = cursor.mock_calls[0][2]["outconverter"]
- self._assert_errorhandler(outconverter, use_read, False)
+ self._assert_errorhandler(outconverter, False)
@_oracle_char_combinations
@testing.requires.python3
def test_encoding_errors_cx_oracle_py3k(
- self, cx_Oracle, cx_oracle_type, use_read
+ self, cx_Oracle, cx_oracle_type,
):
ignore_dialect = cx_oracle.dialect(
dbapi=cx_Oracle, encoding_errors="ignore"
cursor = mock.Mock()
ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
- if use_read:
- eq_(
- cursor.mock_calls,
- [
- mock.call.var(
- mock.ANY,
- None,
- cursor.arraysize,
- encodingErrors="ignore",
- outconverter=mock.ANY,
- )
- ],
- )
- else:
- eq_(
- cursor.mock_calls,
- [
- mock.call.var(
- mock.ANY,
- None,
- cursor.arraysize,
- encodingErrors="ignore",
- )
- ],
- )
+ eq_(
+ cursor.mock_calls,
+ [
+ mock.call.var(
+ mock.ANY, None, cursor.arraysize, encodingErrors="ignore",
+ )
+ ],
+ )
@_oracle_char_combinations
@testing.requires.python3
def test_no_encoding_errors_cx_oracle_py3k(
- self, cx_Oracle, cx_oracle_type, use_read
+ self, cx_Oracle, cx_oracle_type,
):
plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle)
cursor = mock.Mock()
plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
- if use_read:
- eq_(
- cursor.mock_calls,
- [
- mock.call.var(
- mock.ANY, None, cursor.arraysize, outconverter=mock.ANY
- )
- ],
- )
- else:
- eq_(
- cursor.mock_calls,
- [mock.call.var(mock.ANY, None, cursor.arraysize)],
- )
+ eq_(
+ cursor.mock_calls,
+ [mock.call.var(mock.ANY, None, cursor.arraysize)],
+ )
class ComputedReturningTest(fixtures.TablesTest):