]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: format TestRefMismatch more readable
authorChristian Franke <chris@opensourcerouting.org>
Tue, 28 Mar 2017 16:23:47 +0000 (18:23 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Tue, 28 Mar 2017 16:56:38 +0000 (18:56 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
tests/helpers/python/frrtest.py

index 20c854f66c26040088253782851f50dcbc1d334f..21944bcf980b9b9300405c3a43b8bc468d6c0805 100644 (file)
@@ -27,6 +27,7 @@ import sys
 import re
 import inspect
 import os
+import difflib
 
 import frrsix
 
@@ -154,7 +155,18 @@ class TestMultiOut(_TestMultiOut):
 #
 
 class TestRefMismatch(Exception):
-    pass
+    def __init__(self, _test, outtext, reftext):
+        self.outtext = outtext.decode('utf8') if type(outtext) is bytes else outtext
+        self.reftext = reftext.decode('utf8') if type(reftext) is bytes else reftext
+
+    def __str__(self):
+        rv = 'Expected output and actual output differ:\n'
+        rv += '\n'.join(difflib.unified_diff(self.reftext.splitlines(),
+                                             self.outtext.splitlines(),
+                                             'outtext', 'reftext',
+                                             lineterm=''))
+        return rv
+
 class TestExitNonzero(Exception):
     pass