diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2018-08-03 12:21:52 -0300 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-11-27 20:22:14 -0500 |
| commit | 9683a1bb50b71d7cc7caaf7905ce9f5576c293c5 (patch) | |
| tree | d2c483aa68568af3e560d219f8235054952d597d /tests/topotests/lib/topotest.py | |
| parent | fd8582906d7878287b37786c05bfc98187adfe4d (diff) | |
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>
Diffstat (limited to 'tests/topotests/lib/topotest.py')
| -rw-r--r-- | tests/topotests/lib/topotest.py | 8 |
1 files changed, 7 insertions, 1 deletions
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): |
