Fixed DB test cases on PyPy

They weren't working because of the intersection between some monkey
patching in the tests and the fact that ``sqlite3.Connection`` and
``Cursor`` are Python classes on PyPy, but C-extension classes on
CPython. The result was that trying to call the superclass's init
didn't work because the name ``sqlite3.Connection`` pointed to a
different class that wasn't actually the real superclass of
``GreenDBConnection``. Using ``super`` fixes this because the method
called is now always the real superclass's.

Change-Id: Ib45b16c7499883e560877788f13285d0a47cc2cd
This commit is contained in:
Alex Gaynor 2013-12-02 14:24:22 -06:00
parent 93d63dcf75
commit 9b38463b06

View File

@ -100,7 +100,7 @@ class GreenDBConnection(sqlite3.Connection):
timeout = BROKER_TIMEOUT
self.timeout = timeout
self.db_file = database
sqlite3.Connection.__init__(self, database, 0, *args, **kwargs)
super(GreenDBConnection, self).__init__(database, 0, *args, **kwargs)
def cursor(self, cls=None):
if cls is None:
@ -119,7 +119,7 @@ class GreenDBCursor(sqlite3.Cursor):
def __init__(self, *args, **kwargs):
self.timeout = args[0].timeout
self.db_file = args[0].db_file
sqlite3.Cursor.__init__(self, *args, **kwargs)
super(GreenDBCursor, self).__init__(*args, **kwargs)
def execute(self, *args, **kwargs):
return _db_timeout(