Author: cito
Date: Sat Nov 21 09:16:44 2015
New Revision: 570

Log:
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.

Modified:
   branches/4.x/module/TEST_PyGreSQL_classic_connection.py

Modified: branches/4.x/module/TEST_PyGreSQL_classic_connection.py
==============================================================================
--- branches/4.x/module/TEST_PyGreSQL_classic_connection.py     Sat Nov 21 
08:20:28 2015        (r569)
+++ branches/4.x/module/TEST_PyGreSQL_classic_connection.py     Sat Nov 21 
09:16:44 2015        (r570)
@@ -253,12 +253,19 @@
         self.assertEqual(r, result)
 
     def testGetresultLong(self):
-        q = "select 1234567890123456790"
-        result = 1234567890123456790L
+        q = "select 9876543210"
+        result = 9876543210L
         v = self.c.query(q).getresult()[0][0]
         self.assertIsInstance(v, long)
         self.assertEqual(v, result)
 
+    def testGetresultDecimal(self):
+        q = "select 98765432109876543210"
+        result = Decimal(98765432109876543210L)
+        v = self.c.query(q).getresult()[0][0]
+        self.assertIsInstance(v, Decimal)
+        self.assertEqual(v, result)
+
     def testGetresultString(self):
         result = 'Hello, world!'
         q = "select '%s'" % result
@@ -277,12 +284,19 @@
         self.assertEqual(r, result)
 
     def testDictresultLong(self):
-        q = "select 1234567890123456790 as longjohnsilver"
-        result = 1234567890123456790L
+        q = "select 9876543210 as longjohnsilver"
+        result = 9876543210L
         v = self.c.query(q).dictresult()[0]['longjohnsilver']
         self.assertIsInstance(v, long)
         self.assertEqual(v, result)
 
+    def testDictresultDecimal(self):
+        q = "select 98765432109876543210 as longjohnsilver"
+        result = Decimal(98765432109876543210L)
+        v = self.c.query(q).dictresult()[0]['longjohnsilver']
+        self.assertIsInstance(v, Decimal)
+        self.assertEqual(v, result)
+
     def testDictresultString(self):
         result = 'Hello, world!'
         q = "select '%s' as greeting" % result
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to