]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotest: allow passing options to difflib
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 20 Sep 2017 15:04:23 +0000 (12:04 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:12 +0000 (20:22 -0500)
Extend the topotest diff functions to allow receiving difflib options.

tests/topotests/lib/topotest.py

index a41350614d9544f61045cd6e36039c1ed49e9da5..8063598ebaf83bcf89b6e30b1dd47f32161192cb 100644 (file)
@@ -198,20 +198,20 @@ def pid_exists(pid):
     else:
         return True
 
-def get_textdiff(text1, text2, title1="", title2=""):
+def get_textdiff(text1, text2, title1="", title2="", **opts):
     "Returns empty string if same or formatted diff"
 
     diff = '\n'.join(difflib.unified_diff(text1, text2,
-           fromfile=title1, tofile=title2))
+           fromfile=title1, tofile=title2, **opts))
     # Clean up line endings
     diff = os.linesep.join([s for s in diff.splitlines() if s])
     return diff
 
-def difflines(text1, text2, title1='', title2=''):
+def difflines(text1, text2, title1='', title2='', **opts):
     "Wrapper for get_textdiff to avoid string transformations."
     text1 = ('\n'.join(text1.rstrip().splitlines()) + '\n').splitlines(1)
     text2 = ('\n'.join(text2.rstrip().splitlines()) + '\n').splitlines(1)
-    return get_textdiff(text1, text2, title1, title2)
+    return get_textdiff(text1, text2, title1, title2, **opts)
 
 def get_file(content):
     """