]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: improve normalize_text with another case
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Fri, 3 Aug 2018 15:21:52 +0000 (12:21 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:14 +0000 (20:22 -0500)
When normalizing a text also remove trailing whitespace since external
tools might add them. This commit fixes a test failure in ospf_topo1 on
Ubuntu 18.04.1.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
tests/topotests/lib/topotest.py

index b5c9bbe165925f2769a9d145efcc4316a330bff1..d2617c4960d4243bb615ef6053136f206c74ed22 100644 (file)
@@ -297,10 +297,16 @@ def get_file(content):
 
 def normalize_text(text):
     """
-    Strips formating spaces/tabs and carriage returns.
+    Strips formating spaces/tabs, carriage returns and trailing whitespace.
     """
     text = re.sub(r'[ \t]+', ' ', text)
     text = re.sub(r'\r', '', text)
+
+    # Remove whitespace in the middle of text.
+    text = re.sub(r'[ \t]+\n', '\n', text)
+    # Remove whitespace at the end of the text.
+    text = text.rstrip()
+
     return text
 
 def module_present(module, load=True):