From 9683a1bb50b71d7cc7caaf7905ce9f5576c293c5 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Fri, 3 Aug 2018 12:21:52 -0300 Subject: [PATCH] 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 --- tests/topotests/lib/topotest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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): -- 2.39.5