[PATCH] D68920: [LNT] Python 3 support: specify how to sort dict
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 12 15:46:32 PDT 2019
thopre created this revision.
thopre added reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls.
thopre added a parent revision: D68919: [LNT] Python 3 support: import LNT report as text.
To be able to compare 2 lists of dictionaries, test
server/ui/test_roundtrip.py calls sorted on those list so that they are
comparable. However no comparison function is given so it fails on
Python 3 because dictionary are not comparable. This commit adds a key
parameter to sort on the name key of these dictionaries.
https://reviews.llvm.org/D68920
Files:
tests/server/ui/test_roundtrip.py
Index: tests/server/ui/test_roundtrip.py
===================================================================
--- tests/server/ui/test_roundtrip.py
+++ tests/server/ui/test_roundtrip.py
@@ -94,8 +94,10 @@
for k in ['machine', 'run']:
self.assertEqual(before_submit_run[k], after_submit_run[k])
# The order of the tests might have changed, so sort before they are compared.
- before_submit_tests = sorted(before_submit_run['tests'])
- after_submit_tests = sorted(after_submit_run['tests'])
+ before_submit_tests = sorted(before_submit_run['tests'],
+ key=lambda test: test['id'])
+ after_submit_tests = sorted(after_submit_run['tests'],
+ key=lambda test: test['id'])
for i, _ in enumerate(before_submit_tests):
before_submit_tests[i]['run_id'] = 1234
after_submit_tests[i]['run_id'] = 1234
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68920.224761.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191012/7e98e43f/attachment.bin>
More information about the llvm-commits
mailing list