Skip to content

Commit 2c828b8

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: specify how to sort dict
Summary: 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. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls, leandron, PrzemekWirkus Reviewed By: cmatthews Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D68920
1 parent 709b097 commit 2c828b8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/server/ui/test_roundtrip.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ def _compare_results(self, after_submit_run, before_submit_run):
9494
for k in ['machine', 'run']:
9595
self.assertEqual(before_submit_run[k], after_submit_run[k])
9696
# The order of the tests might have changed, so sort before they are compared.
97-
before_submit_tests = sorted(before_submit_run['tests'])
98-
after_submit_tests = sorted(after_submit_run['tests'])
97+
before_submit_tests = sorted(before_submit_run['tests'],
98+
key=lambda test: test['id'])
99+
after_submit_tests = sorted(after_submit_run['tests'],
100+
key=lambda test: test['id'])
99101
for i, _ in enumerate(before_submit_tests):
100102
before_submit_tests[i]['run_id'] = 1234
101103
after_submit_tests[i]['run_id'] = 1234

0 commit comments

Comments
 (0)