Author: cito
Date: Sun Feb 7 09:28:49 2016
New Revision: 833
Log:
Small fixes to make trunk run with Python 2.6 again
Modified:
trunk/pg.py
trunk/tests/test_classic_dbwrapper.py
Modified: trunk/pg.py
==============================================================================
--- trunk/pg.py Sun Feb 7 07:29:50 2016 (r832)
+++ trunk/pg.py Sun Feb 7 09:28:49 2016 (r833)
@@ -192,8 +192,8 @@
self[key] = typ
self['_%s' % key] = '%s[]' % typ
- @staticmethod
- def __missing__(key):
+ # this could be a static method in Python > 2.6
+ def __missing__(self, key):
return 'text'
_simpletypes = _SimpleTypes()
Modified: trunk/tests/test_classic_dbwrapper.py
==============================================================================
--- trunk/tests/test_classic_dbwrapper.py Sun Feb 7 07:29:50 2016
(r832)
+++ trunk/tests/test_classic_dbwrapper.py Sun Feb 7 09:28:49 2016
(r833)
@@ -210,7 +210,10 @@
'unescape_bytea', 'update', 'upsert',
'use_regtypes', 'user',
]
- db_attributes = [a for a in dir(self.db)
+ # __dir__ is not called in Python 2.6 for old-style classes
+ db_attributes = dir(self.db) if hasattr(
+ self.db.__class__, '__class__') else self.db.__dir__()
+ db_attributes = [a for a in db_attributes
if not a.startswith('_')]
self.assertEqual(attributes, db_attributes)
@@ -888,6 +891,11 @@
self.assertEqual(r, (3, 2.5, 'hello', t))
q = f("select %s, %s, %s, %s", (3, 2.5, 'hello', True), inline=True)
r = q.getresult()[0]
+ if isinstance(r[1], Decimal):
+ # Python 2.6 cannot compare float and Decimal
+ r = list(r)
+ r[1] = float(r[1])
+ r = tuple(r)
self.assertEqual(r, (3, 2.5, 'hello', t))
def testPkey(self):
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql