mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
tests/qapi-schema: Hide OrderedDict in test output
Since commit 5d83b9a130
"qapi: replace if condition list with dict
{'all': [...]}", we represent if conditionals as trees consisting of
OrderedDict, list and str. This results in less than legible test
output. For instance:
if OrderedDict([('not', OrderedDict([('any', [OrderedDict([('not', 'TEST_IF_EVT')]), OrderedDict([('not', 'TEST_IF_STRUCT')])])]))])
We intend to replace OrderedDict by dict when we get Python 3.7, which
will result in more legible output:
if {'not': {'any': [{'not': 'TEST_IF_EVT'}, {'not': 'TEST_IF_STRUCT'}]}}
Can't wait: put in a hack to get that now, with a comment to revert it
when we replace OrderedDict.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-11-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
555dd1aaa6
commit
9c629fa834
3 changed files with 28 additions and 19 deletions
|
@ -94,8 +94,17 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
|||
|
||||
@staticmethod
|
||||
def _print_if(ifcond, indent=4):
|
||||
# TODO Drop this hack after replacing OrderedDict by plain
|
||||
# dict (requires Python 3.7)
|
||||
def _massage(subcond):
|
||||
if isinstance(subcond, str):
|
||||
return subcond
|
||||
if isinstance(subcond, list):
|
||||
return [_massage(val) for val in subcond]
|
||||
return {key: _massage(val) for key, val in subcond.items()}
|
||||
|
||||
if ifcond.is_present():
|
||||
print('%sif %s' % (' ' * indent, ifcond.ifcond))
|
||||
print('%sif %s' % (' ' * indent, _massage(ifcond.ifcond)))
|
||||
|
||||
@classmethod
|
||||
def _print_features(cls, features, indent=4):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue