[IMP] tools/yaml_import: Try to explain values of failed assertions
When some assertion fails, eg. "a == 4" , try to break it down and eval the parts so that we see the real "8 == 4" data. bzr revid: odo@openerp.com-20100902113025-ef3gdit4r6ipwoxn
This commit is contained in:
parent
cf56cf5d1e
commit
ca72c6b1ce
|
@ -250,6 +250,25 @@ class YamlInterpreter(object):
|
|||
if not success:
|
||||
msg = 'Assertion "%s" FAILED\ntest: %s\n'
|
||||
args = (assertion.string, test)
|
||||
for aop in ('==', '!=', '<>', 'in', 'not in', '>=', '<=', '>', '<'):
|
||||
if aop in test:
|
||||
left, right = test.split(aop,1)
|
||||
lmsg = ''
|
||||
rmsg = ''
|
||||
try:
|
||||
lmsg = unsafe_eval(left, self.eval_context, RecordDictWrapper(record))
|
||||
except Exception, e:
|
||||
lmsg = '<exc>'
|
||||
|
||||
try:
|
||||
rmsg = unsafe_eval(right, self.eval_context, RecordDictWrapper(record))
|
||||
except Exception, e:
|
||||
rmsg = '<exc>'
|
||||
|
||||
msg += 'values: ! %s %s %s'
|
||||
args += ( lmsg, aop, rmsg )
|
||||
break
|
||||
|
||||
self._log_assert_failure(assertion.severity, msg, *args)
|
||||
return
|
||||
else: # all tests were successful for this assertion tag (no break)
|
||||
|
|
Loading…
Reference in New Issue