summaryrefslogtreecommitdiffstats
path: root/tests/topotests/conftest.py
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@gmail.com>2017-06-29 17:18:46 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-11-28 02:22:11 +0100
commit3668ed8dc2df70ca3ff4a1ea99b85894ba5b3a11 (patch)
treeca921c7a758cb6773e70cb837218b95c5a9316dc /tests/topotests/conftest.py
parenttopogen: don't backtrace when topogen is not used (diff)
downloadfrr-3668ed8dc2df70ca3ff4a1ea99b85894ba5b3a11.tar.xz
frr-3668ed8dc2df70ca3ff4a1ea99b85894ba5b3a11.zip
topotest: improve json_cmp assert output
Create a specialized assert and json_cmp() result to improve the comparison output. With this we also got a way to display all comparison failures instead of just the first one.
Diffstat (limited to 'tests/topotests/conftest.py')
-rwxr-xr-xtests/topotests/conftest.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py
index a8bc53994..cea7ad448 100755
--- a/tests/topotests/conftest.py
+++ b/tests/topotests/conftest.py
@@ -3,6 +3,7 @@ Topotest conftest.py file.
"""
from lib.topogen import get_topogen
+from lib.topotest import json_cmp_result
import pytest
def pytest_addoption(parser):
@@ -27,3 +28,15 @@ def pytest_runtest_call():
tgen.mininet_cli()
pytest.exit('the topology executed successfully')
+
+def pytest_assertrepr_compare(op, left, right):
+ """
+ Show proper assertion error message for json_cmp results.
+ """
+ json_result = left
+ if not isinstance(json_result, json_cmp_result):
+ json_result = right
+ if not isinstance(json_result, json_cmp_result):
+ return None
+
+ return json_result.errors