From: Rafael Zalamena Date: Fri, 3 Aug 2018 15:21:52 +0000 (-0300) Subject: lib: improve normalize_text with another case X-Git-Tag: frr-7.1-dev~151^2~46 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9683a1bb50b71d7cc7caaf7905ce9f5576c293c5;p=matthieu%2Ffrr.git 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 --- diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index b5c9bbe165..d2617c4960 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -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):