[MERGE] trunk
bzr revid: al@openerp.com-20140317223549-gyhpe8dkzaw0qe7z
This commit is contained in:
commit
0b7a673821
|
@ -488,7 +488,6 @@ class FieldConverter(osv.AbstractModel):
|
|||
A default configuration key is ``widget`` which can override the
|
||||
field's own ``_type``.
|
||||
"""
|
||||
content = None
|
||||
try:
|
||||
content = self.record_to_html(
|
||||
cr, uid, field_name, record,
|
||||
|
@ -503,12 +502,14 @@ class FieldConverter(osv.AbstractModel):
|
|||
field_name, record._model._name, exc_info=True)
|
||||
content = None
|
||||
|
||||
g_att += ''.join(
|
||||
' %s="%s"' % (name, werkzeug.utils.escape(value))
|
||||
for name, value in self.attributes(
|
||||
cr, uid, field_name, record, options,
|
||||
source_element, g_att, t_att, qweb_context)
|
||||
)
|
||||
if context and context.get('inherit_branding'):
|
||||
# add branding attributes
|
||||
g_att += ''.join(
|
||||
' %s="%s"' % (name, werkzeug.utils.escape(value))
|
||||
for name, value in self.attributes(
|
||||
cr, uid, field_name, record, options,
|
||||
source_element, g_att, t_att, qweb_context)
|
||||
)
|
||||
|
||||
return self.render_element(cr, uid, source_element, t_att, g_att,
|
||||
qweb_context, content)
|
||||
|
|
|
@ -14,7 +14,8 @@ class TestQWebTField(common.TransactionCase):
|
|||
self.engine = self.registry('ir.qweb')
|
||||
|
||||
def context(self, values):
|
||||
return ir_qweb.QWebContext(self.cr, self.uid, values)
|
||||
return ir_qweb.QWebContext(
|
||||
self.cr, self.uid, values, context={'inherit_branding': True})
|
||||
|
||||
def test_trivial(self):
|
||||
field = document.createElement('span')
|
||||
|
|
|
@ -112,11 +112,14 @@ class TestCurrencyExport(TestExport):
|
|||
'widget': 'monetary',
|
||||
'display_currency': 'c2'
|
||||
}
|
||||
context = dict(inherit_branding=True)
|
||||
converted = converter.to_html(
|
||||
self.cr, self.uid, 'value', obj, options,
|
||||
doc.createElement('span'),
|
||||
{'field': 'obj.value', 'field-options': json.dumps(options)},
|
||||
'', ir_qweb.QWebContext(self.cr, self.uid, {'obj': obj, 'c2': dest, }))
|
||||
'', ir_qweb.QWebContext(self.cr, self.uid, {'obj': obj, 'c2': dest, }),
|
||||
context=context,
|
||||
)
|
||||
return converted
|
||||
|
||||
def test_currency_post(self):
|
||||
|
|
|
@ -245,7 +245,7 @@ class WebRequest(object):
|
|||
|
||||
if self._cr:
|
||||
# Dont commit test cursors
|
||||
if not openerp.tests.common.release_test_cursor(self.session_id):
|
||||
if not openerp.tests.common.release_test_cursor(self._cr):
|
||||
if exc_type is None:
|
||||
self._cr.commit()
|
||||
self._cr.close()
|
||||
|
@ -425,7 +425,7 @@ class JsonRequest(WebRequest):
|
|||
response['id'] = self.jsonrequest.get('id')
|
||||
response["result"] = self._call_function(**self.params)
|
||||
except AuthenticationError, e:
|
||||
_logger.exception("Exception during JSON request handling.")
|
||||
_logger.exception("JSON-RPC AuthenticationError in %s.", self.httprequest.path)
|
||||
se = serialize_exception(e)
|
||||
error = {
|
||||
'code': 100,
|
||||
|
@ -433,7 +433,9 @@ class JsonRequest(WebRequest):
|
|||
'data': se
|
||||
}
|
||||
except Exception, e:
|
||||
_logger.exception("Exception during JSON request handling.")
|
||||
# Mute test cursor error for runbot
|
||||
if not (openerp.tools.config['test_enable'] and isinstance(e, psycopg2.OperationalError)):
|
||||
_logger.exception("JSON-RPC Exception in %s.", self.httprequest.path)
|
||||
se = serialize_exception(e)
|
||||
error = {
|
||||
'code': 200,
|
||||
|
|
|
@ -187,6 +187,10 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules=
|
|||
# Yamel test
|
||||
report.record_result(load_test(module_name, idref, mode))
|
||||
# Python tests
|
||||
ir_http = registry['ir.http']
|
||||
if hasattr(ir_http, '_routing_map'):
|
||||
# Force routing map to be rebuilt between each module test suite
|
||||
del(ir_http._routing_map)
|
||||
report.record_result(openerp.modules.module.run_unit_tests(module_name, cr.dbname))
|
||||
|
||||
processed_modules.append(package.name)
|
||||
|
|
|
@ -38,7 +38,6 @@ import openerp.release as release
|
|||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_test_logger = logging.getLogger('openerp.tests')
|
||||
|
||||
# addons path as a list
|
||||
ad_paths = []
|
||||
|
@ -340,7 +339,8 @@ def get_test_modules(module):
|
|||
|
||||
# Use a custom stream object to log the test executions.
|
||||
class TestStream(object):
|
||||
def __init__(self):
|
||||
def __init__(self, logger_name='openerp.tests'):
|
||||
self.logger = logging.getLogger(logger_name)
|
||||
self.r = re.compile(r'^-*$|^ *... *$|^ok$')
|
||||
def flush(self):
|
||||
pass
|
||||
|
@ -352,7 +352,7 @@ class TestStream(object):
|
|||
if not first:
|
||||
c = '` ' + c
|
||||
first = False
|
||||
_test_logger.info(c)
|
||||
self.logger.info(c)
|
||||
|
||||
current_test = None
|
||||
|
||||
|
@ -369,9 +369,9 @@ def run_unit_tests(module_name, dbname):
|
|||
for m in mods:
|
||||
tests = unwrap_suite(unittest2.TestLoader().loadTestsFromModule(m))
|
||||
suite = unittest2.TestSuite(itertools.ifilter(runs_at_install, tests))
|
||||
_logger.info('module %s: running test %s.', module_name, m.__name__)
|
||||
_logger.info('running %s tests.', m.__name__)
|
||||
|
||||
result = unittest2.TextTestRunner(verbosity=2, stream=TestStream()).run(suite)
|
||||
result = unittest2.TextTestRunner(verbosity=2, stream=TestStream(m.__name__)).run(suite)
|
||||
|
||||
if not result.wasSuccessful():
|
||||
r = False
|
||||
|
|
|
@ -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__)
|
||||
|
@ -48,10 +49,9 @@ def acquire_test_cursor(session_id):
|
|||
cr._test_lock.acquire()
|
||||
return cr
|
||||
|
||||
def release_test_cursor(session_id):
|
||||
def release_test_cursor(cr):
|
||||
if openerp.tools.config['test_enable']:
|
||||
cr = HTTP_SESSION.get(session_id)
|
||||
if cr:
|
||||
if hasattr(cr, '_test_lock'):
|
||||
cr._test_lock.release()
|
||||
return True
|
||||
return False
|
||||
|
@ -228,12 +228,12 @@ class HttpCase(TransactionCase):
|
|||
line = str(line)
|
||||
|
||||
# relay everything from console.log, even 'ok' or 'error...' lines
|
||||
_logger.debug("phantomjs: %s", line)
|
||||
_logger.info("phantomjs: %s", line)
|
||||
|
||||
if line == "ok":
|
||||
break
|
||||
if line.startswith("error"):
|
||||
line_ = self.line[6:]
|
||||
line_ = line[6:]
|
||||
# when error occurs the execution stack may be sent as as JSON
|
||||
try:
|
||||
line_ = json.loads(line_)
|
||||
|
@ -242,7 +242,7 @@ class HttpCase(TransactionCase):
|
|||
self.fail(line_ or "phantomjs test failed")
|
||||
|
||||
def phantom_run(self, cmd, timeout):
|
||||
_logger.debug('phantom_run executing %s', ' '.join(cmd))
|
||||
_logger.info('phantom_run executing %s', ' '.join(cmd))
|
||||
try:
|
||||
phantom = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
except OSError:
|
||||
|
@ -253,7 +253,7 @@ class HttpCase(TransactionCase):
|
|||
# kill phantomjs if phantom.exit() wasn't called in the test
|
||||
if phantom.poll() is None:
|
||||
phantom.terminate()
|
||||
_logger.debug("phantom_run execution finished")
|
||||
_logger.info("phantom_run execution finished")
|
||||
|
||||
def phantom_jsfile(self, jsfile, timeout=30, **kw):
|
||||
options = {
|
||||
|
|
Loading…
Reference in New Issue