From 32e2cd5eb9ad86ae95d8a1e1de5e1d934b2f6f7a Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 14 Apr 2023 11:39:05 +0200 Subject: linux: Fix broken assertDevs() device loop The test uses a generator to get the list of basenames for the devices: names = (n.split('/')[-1] for n in devs) Unfortunately, using that "names" varible will consume the generator, and our array will be lost. When passing a device dictionary, this code: print(sorted(names)) print(sorted(names)) will yield: ['battery_hidpp_battery_0'] [] Save the sorted array, and use that to test for properties equality. --- src/linux/integration-test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py index 0898e0d..b04454c 100755 --- a/src/linux/integration-test.py +++ b/src/linux/integration-test.py @@ -285,9 +285,9 @@ class Tests(dbusmock.DBusTestCase): def assertDevs(self, expected): devs = self.proxy.EnumerateDevices() - names = (n.split('/')[-1] for n in devs) + names = sorted(n.split('/')[-1] for n in devs) - self.assertEqual(sorted(names), sorted(expected.keys())) + self.assertEqual(names, sorted(expected.keys())) for n in names: props = self.get_dbus_dev_properties(n) -- cgit v1.2.1