Skip to content

Commit

Permalink
Merge pull request FRRouting#299 from opensourcerouting/test-ref-out
Browse files Browse the repository at this point in the history
tests: format TestRefMismatch more readable
  • Loading branch information
donaldsharp authored Mar 30, 2017
2 parents aba41ec + 1ea8289 commit fdbfd65
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/helpers/python/frrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import re
import inspect
import os
import difflib

import frrsix

Expand Down Expand Up @@ -154,7 +155,18 @@ def _okfail(self, line, okfail=re_okfail):
#

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

Expand Down

0 comments on commit fdbfd65

Please sign in to comment.