Changeset 570 for branches/4.x


Ignore:
Timestamp:
Nov 21, 2015, 9:16:44 AM (4 years ago)
Author:
cito
Message:

Improve tests for long ints under Python 2

PyGreSQL returns longs for Postgres bigints, even though theoretically
it could return ints in the case of a 64bit Python. But that's ok
because it makes the behavior more consistent and because the int/long
split becomes irrelevant in Python 3 anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/module/TEST_PyGreSQL_classic_connection.py

    r565 r570  
    254254
    255255    def testGetresultLong(self):
    256         q = "select 1234567890123456790"
    257         result = 1234567890123456790L
     256        q = "select 9876543210"
     257        result = 9876543210L
    258258        v = self.c.query(q).getresult()[0][0]
    259259        self.assertIsInstance(v, long)
     260        self.assertEqual(v, result)
     261
     262    def testGetresultDecimal(self):
     263        q = "select 98765432109876543210"
     264        result = Decimal(98765432109876543210L)
     265        v = self.c.query(q).getresult()[0][0]
     266        self.assertIsInstance(v, Decimal)
    260267        self.assertEqual(v, result)
    261268
     
    278285
    279286    def testDictresultLong(self):
    280         q = "select 1234567890123456790 as longjohnsilver"
    281         result = 1234567890123456790L
     287        q = "select 9876543210 as longjohnsilver"
     288        result = 9876543210L
    282289        v = self.c.query(q).dictresult()[0]['longjohnsilver']
    283290        self.assertIsInstance(v, long)
     291        self.assertEqual(v, result)
     292
     293    def testDictresultDecimal(self):
     294        q = "select 98765432109876543210 as longjohnsilver"
     295        result = Decimal(98765432109876543210L)
     296        v = self.c.query(q).dictresult()[0]['longjohnsilver']
     297        self.assertIsInstance(v, Decimal)
    284298        self.assertEqual(v, result)
    285299
Note: See TracChangeset for help on using the changeset viewer.