From 64f103416fe614a50be336b05a4d95e82d7ea9a2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 13 Dec 2019 10:05:00 +0100 Subject: [PATCH] clients/tests: support Util.replace_text_sort_list() helper This will be necessary to sort a list of text that contains text to replace. The use case is to get all UUIDs from the server, but some of these UUIDs are dynamic. So, in order to have a fixed sort order, we need to handle sorting the list, based on the replacement. (cherry picked from commit 347253be2f3db7185dadecbd4fc10e172d5dc141) --- clients/tests/test-client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py index b1b912a273..4a0201ccca 100755 --- a/clients/tests/test-client.py +++ b/clients/tests/test-client.py @@ -309,6 +309,12 @@ class Util: bb = bb.decode('utf-8') return bb + @staticmethod + def replace_text_sort_list(lst, replace_arr): + lst = [ (Util.replace_text(elem, replace_arr), elem) for elem in lst ] + lst = sorted(lst) + lst = [ tup[1] for tup in lst ] + return list(lst) @staticmethod def debug_dbus_interface():