summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/log.py
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-04-27 19:48:09 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-04-27 20:24:50 +0200
commit2694a9d329dfefc01e5e8d0477177589781d9585 (patch)
tree1123e72ebd42332025e507d8bfe075c1b87a0e6c /src/osmo_gsm_tester/log.py
parentac45a223560c8b45f872d3de7ab4629a308e2e77 (diff)
fix 'make check'
Apply various fixes that arose from test case code rot. These tests will now be used to verify patches submitted to gerrit, so they need to be up to par. Change-Id: I5277be0c434226d9d02e038f0bc72fd2557350c1 Related: OS#2215
Diffstat (limited to 'src/osmo_gsm_tester/log.py')
-rw-r--r--src/osmo_gsm_tester/log.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py
index 3e96999..b581e2c 100644
--- a/src/osmo_gsm_tester/log.py
+++ b/src/osmo_gsm_tester/log.py
@@ -24,6 +24,8 @@ import traceback
import contextlib
from inspect import getframeinfo, stack
+from .util import is_dict
+
L_ERR = 30
L_LOG = 20
L_DBG = 10
@@ -512,14 +514,20 @@ def run_logging_exceptions(func, *func_args, return_on_failure=None, **func_kwar
log_exn()
return return_on_failure
+def _compose_named_items(item):
+ 'make sure dicts are output sorted, for test expectations'
+ if is_dict(item):
+ return '{%s}' % (', '.join(
+ ['%s=%s' % (k, _compose_named_items(v))
+ for k,v in sorted(item.items())]))
+ return repr(item)
+
def compose_message(messages, named_items):
msgs = [str(m) for m in messages]
if named_items:
# unfortunately needs to be sorted to get deterministic results
- msgs.append('{%s}' %
- (', '.join(['%s=%r' % (k,v)
- for k,v in sorted(named_items.items())])))
+ msgs.append(_compose_named_items(named_items))
return ' '.join(msgs)