diff options
author | Bastien Nocera <hadess@hadess.net> | 2023-04-14 11:39:05 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2023-04-14 13:50:19 +0200 |
commit | 32e2cd5eb9ad86ae95d8a1e1de5e1d934b2f6f7a (patch) | |
tree | 15292587075fbea006f575a761b29c243000328b | |
parent | a5acbad7f1528b4d2ddaeeb06f33a547cf7661b1 (diff) | |
download | upower-32e2cd5eb9ad86ae95d8a1e1de5e1d934b2f6f7a.tar.gz |
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.
-rwxr-xr-x | src/linux/integration-test.py | 4 |
1 files 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) |