Exemplo n.º 1
0
 def testBinaryOutputMethods(self):
     methods = (
         ("float8send", 22.2),
         ("timestamp_send", datetime.datetime(2001, 2, 3, 4, 5, 6, 789)),
         ("byteasend", dbapi.Binary("\x01\x02")),
         ("interval_send", types.Interval(1234567, 123, 123)),
     )
     for method_out, value in methods:
         self.cursor.execute("SELECT %s(%%s) as f1" % method_out, (value, ))
         retval = self.cursor.fetchall()
         self.assert_(retval[0][0] == getattr(types, method_out)(
             value, integer_datetimes=db.conn.c._integer_datetimes))
Exemplo n.º 2
0
 def testBinaryOutputMethods(self):
     methods = (
         ("float8send", 22.2),
         ("timestamp_send", datetime.datetime(2001, 2, 3, 4, 5, 6, 789)),
         ("byteasend", dbapi.Binary(b("\x01\x02"))),
         ("interval_send", types.Interval(1234567, 123, 123)),
     )
     for method_out, value in methods:
         self.cursor.execute("SELECT %s(%%s) as f1" % method_out, (value, ))
         retval = self.cursor.fetchall()
         self.assertEqual(retval[0][0],
                          self.db.make_params((value, ))[0][2](value))
Exemplo n.º 3
0
 def testByteaRoundtrip(self):
     self.cursor.execute("SELECT %s as f1",
                         (dbapi.Binary("\x00\x01\x02\x03\x02\x01\x00"), ))
     retval = self.cursor.fetchall()
     self.assert_(retval[0][0] == "\x00\x01\x02\x03\x02\x01\x00",
                  "retrieved value match failed")
Exemplo n.º 4
0
 def testByteaRoundtrip(self):
     self.cursor.execute(
         "SELECT %s as f1",
         (dbapi.Binary(b("\x00\x01\x02\x03\x02\x01\x00")), ))
     retval = self.cursor.fetchall()
     self.assertEqual(retval[0][0], b("\x00\x01\x02\x03\x02\x01\x00"))