[FIX] tests dont generate traceback on aborted test requests
bzr revid: al@openerp.com-20140317124343-kgesa5c215z19vpn
This commit is contained in:
parent
d3c7750b96
commit
09deba4826
|
@ -148,7 +148,7 @@ class Cursor(object):
|
|||
def check(f):
|
||||
@wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
if self.__closed:
|
||||
if self._closed:
|
||||
msg = 'Unable to use a closed cursor.'
|
||||
if self.__closer:
|
||||
msg += ' It was closed at %s, line %s' % self.__closer
|
||||
|
@ -165,7 +165,7 @@ class Cursor(object):
|
|||
self.sql_log = _logger.isEnabledFor(logging.DEBUG)
|
||||
|
||||
self.sql_log_count = 0
|
||||
self.__closed = True # avoid the call of close() (by __del__) if an exception
|
||||
self._closed = True # avoid the call of close() (by __del__) if an exception
|
||||
# is raised by any of the following initialisations
|
||||
self._pool = pool
|
||||
self.dbname = dbname
|
||||
|
@ -180,7 +180,7 @@ class Cursor(object):
|
|||
self.__caller = frame_codeinfo(currentframe(),2)
|
||||
else:
|
||||
self.__caller = False
|
||||
self.__closed = False # real initialisation value
|
||||
self._closed = False # real initialisation value
|
||||
self.autocommit(False)
|
||||
self.__closer = False
|
||||
|
||||
|
@ -189,7 +189,7 @@ class Cursor(object):
|
|||
self.cache = {}
|
||||
|
||||
def __del__(self):
|
||||
if not self.__closed and not self._cnx.closed:
|
||||
if not self._closed and not self._cnx.closed:
|
||||
# Oops. 'self' has not been closed explicitly.
|
||||
# The cursor will be deleted by the garbage collector,
|
||||
# but the database connection is not put back into the connection
|
||||
|
@ -302,7 +302,7 @@ class Cursor(object):
|
|||
# collected as fast as they should). The problem is probably due in
|
||||
# part because browse records keep a reference to the cursor.
|
||||
del self._obj
|
||||
self.__closed = True
|
||||
self._closed = True
|
||||
|
||||
# Clean the underlying connection.
|
||||
self._cnx.rollback()
|
||||
|
|
|
@ -15,9 +15,10 @@ import time
|
|||
import unittest2
|
||||
import urllib2
|
||||
import xmlrpclib
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import werkzeug
|
||||
|
||||
import openerp
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
@ -46,6 +47,8 @@ def acquire_test_cursor(session_id):
|
|||
cr = HTTP_SESSION.get(session_id)
|
||||
if cr:
|
||||
cr._test_lock.acquire()
|
||||
if cr._closed:
|
||||
werkzeug.exceptions.abort(500)
|
||||
return cr
|
||||
|
||||
def release_test_cursor(cr):
|
||||
|
|
Loading…
Reference in New Issue