Changeset 833 for trunk/tests


Ignore:
Timestamp:
Feb 7, 2016, 9:28:49 AM (4 years ago)
Author:
cito
Message:

Small fixes to make trunk run with Python 2.6 again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_classic_dbwrapper.py

    r823 r833  
    211211            'use_regtypes', 'user',
    212212        ]
    213         db_attributes = [a for a in dir(self.db)
     213        # __dir__ is not called in Python 2.6 for old-style classes
     214        db_attributes = dir(self.db) if hasattr(
     215            self.db.__class__, '__class__') else self.db.__dir__()
     216        db_attributes = [a for a in db_attributes
    214217            if not a.startswith('_')]
    215218        self.assertEqual(attributes, db_attributes)
     
    889892        q = f("select %s, %s, %s, %s", (3, 2.5, 'hello', True), inline=True)
    890893        r = q.getresult()[0]
     894        if isinstance(r[1], Decimal):
     895            # Python 2.6 cannot compare float and Decimal
     896            r = list(r)
     897            r[1] = float(r[1])
     898            r = tuple(r)
    891899        self.assertEqual(r, (3, 2.5, 'hello', t))
    892900
Note: See TracChangeset for help on using the changeset viewer.