[devtools] qunit: show helpful data when an assertion fails
authorRémi Cardona <remi.cardona@logilab.fr>
Thu, 21 May 2015 16:20:04 +0200
changeset 10432 f5ec46a6867a
parent 10431 7628a14d2209
child 10433 523a7f098066
[devtools] qunit: show helpful data when an assertion fails Related to #5533333.
devtools/qunit.py
--- a/devtools/qunit.py	Wed May 20 17:25:40 2015 +0200
+++ b/devtools/qunit.py	Thu May 21 16:20:04 2015 +0200
@@ -212,7 +212,15 @@
     def handle_log(self):
         result = self._cw.form['result']
         message = self._cw.form.get('message', '<no message>')
-        self._log_stack.append('%s: %s' % (result, message))
+        actual = self._cw.form.get('actual')
+        expected = self._cw.form.get('expected')
+        source = self._cw.form.get('source')
+        log = '%s: %s' % (result, message)
+        if result == 'false' and actual is not None and expected is not None:
+            log += ' (got: %s, expected: %s)' % (actual, expected)
+            if source is not None:
+                log += '\n' + source
+        self._log_stack.append(log)
 
 
 class QUnitView(View):
@@ -276,6 +284,9 @@
                            url: BASE_URL + 'qunit_result',
                            data: {"event": "log",
                                   "result": details.result,
+                                  "actual": details.actual,
+                                  "expected": details.expected,
+                                  "source": details.source,
                                   "message": details.message},
                            async: false});
             });''')