lib: improve normalize_text with another case

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>
This commit is contained in:
Rafael Zalamena 2018-08-03 12:21:52 -03:00 committed by Donald Sharp
parent fd8582906d
commit 9683a1bb50

View File

@ -297,10 +297,16 @@ def get_file(content):
def normalize_text(text): 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'[ \t]+', ' ', text)
text = re.sub(r'\r', '', 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 return text
def module_present(module, load=True): def module_present(module, load=True):