diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-09-05 03:29:20 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-09-05 03:29:20 +0000 |
| commit | 0b292e8842851dd0ebb127ab1cd6131eefa288fe (patch) | |
| tree | c035ef973e0cab3ac552b419c573423ba3ea4ff5 /test/sql | |
| parent | ebcdb289d9dea98ac57fa6d2e410decb86febc7f (diff) | |
| download | sqlalchemy-0b292e8842851dd0ebb127ab1cd6131eefa288fe.tar.gz | |
- the Binary type now returns data as a Python string
(or a "bytes" type in Python 3), instead of the built-
in "buffer" type. This allows symmetric round trips
of binary data. [ticket:1524]
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_types.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/test/sql/test_types.py b/test/sql/test_types.py index cede11cc5..f57347115 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -401,21 +401,29 @@ class BinaryTest(TestBase, AssertsExecutionResults): for stmt in ( binary_table.select(order_by=binary_table.c.primary_id), - text("select * from binary_table order by binary_table.primary_id", typemap={'pickled':PickleType, 'mypickle':MyPickleType}, bind=testing.db) + text( + "select * from binary_table order by binary_table.primary_id", + typemap={'pickled':PickleType, 'mypickle':MyPickleType, 'data':Binary, 'data_slice':Binary}, + bind=testing.db) ): - eq_data = lambda x, y: eq_(list(x), list(y)) - if util.jython: - _eq_data = eq_data - def eq_data(x, y): - # Jython currently returns arrays - from array import ArrayType - if isinstance(y, ArrayType): - return eq_(x, y.tostring()) - return _eq_data(x, y) + #if util.jython: + # TODO: may need to modify Binary type directly + # to detect jython if something other than str()/bytes() + # is needed to convert from raw to string/bytes. + # ArrayType should no longer be expected here though. + # users who want raw ArrayType can of course create their + # own BinaryType that does no conversion. + #_eq_data = eq_data + #def eq_data(x, y): + # # Jython currently returns arrays + # from array import ArrayType + # if isinstance(y, ArrayType): + # return eq_(x, y.tostring()) + # return _eq_data(x, y) l = stmt.execute().fetchall() - eq_data(stream1, l[0]['data']) - eq_data(stream1[0:100], l[0]['data_slice']) - eq_data(stream2, l[1]['data']) + eq_(stream1, l[0]['data']) + eq_(stream1[0:100], l[0]['data_slice']) + eq_(stream2, l[1]['data']) eq_(testobj1, l[0]['pickled']) eq_(testobj2, l[1]['pickled']) eq_(testobj3.moredata, l[0]['mypickle'].moredata) |
