summaryrefslogtreecommitdiff
path: root/tests/test_lobject.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-01-08 23:47:24 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-01-10 00:46:51 +0000
commitf63167a92c2124620bc37e6c3f217d2781f8124e (patch)
treead344457be8c15fb31235896608fd6df6f2b58de /tests/test_lobject.py
parent2cde9033acdcdea86da1c161e0aaec8f9bf441a9 (diff)
downloadpsycopg2-f63167a92c2124620bc37e6c3f217d2781f8124e.tar.gz
Added tests to check large objects decoding
Diffstat (limited to 'tests/test_lobject.py')
-rwxr-xr-xtests/test_lobject.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/test_lobject.py b/tests/test_lobject.py
index b5d5d63..7f600e3 100755
--- a/tests/test_lobject.py
+++ b/tests/test_lobject.py
@@ -167,9 +167,34 @@ class LargeObjectTests(LargeObjectMixin, unittest.TestCase):
lo.close()
lo = self.conn.lobject(lo.oid)
- self.assertEqual(lo.read(4), b("some"))
+ x = lo.read(4)
+ self.assertEqual(type(x), type(''))
+ self.assertEqual(x, "some")
+ self.assertEqual(lo.read(), " data")
+
+ def test_read_binary(self):
+ lo = self.conn.lobject()
+ length = lo.write(b("some data"))
+ lo.close()
+
+ lo = self.conn.lobject(lo.oid, "rb")
+ x = lo.read(4)
+ self.assertEqual(type(x), type(b('')))
+ self.assertEqual(x, "some")
self.assertEqual(lo.read(), b(" data"))
+ def test_read_text(self):
+ lo = self.conn.lobject()
+ snowman = u"\u2603"
+ length = lo.write(u"some data " + snowman)
+ lo.close()
+
+ lo = self.conn.lobject(lo.oid, "rt")
+ x = lo.read(4)
+ self.assertEqual(type(x), type(u''))
+ self.assertEqual(x, u"some")
+ self.assertEqual(lo.read(), u" data " + snowman)
+
def test_read_large(self):
lo = self.conn.lobject()
data = b("data") * 1000000