From d6ef7bcfc8ca15b75c1a3dc930cc964d48971f32 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 9 Sep 2020 11:39:45 +0200 Subject: [PATCH] tests: Fix one of the tests for slower machines ====================================================================== FAIL: test_intel_pstate_balance (__main__.Tests) Intel P-State driver (balance) ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/power-profiles-daemon-0.1/tests/integration-test", line 375, in test_intel_pstate_balance self.assertEqual(contents, b'balance_power') AssertionError: b'' != b'balance_power' ---------------------------------------------------------------------- --- tests/integration-test | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/integration-test b/tests/integration-test index 5393051..028e027 100755 --- a/tests/integration-test +++ b/tests/integration-test @@ -208,6 +208,11 @@ class Tests(dbusmock.DBusTestCase): return f.read() return None + def read_file(self, path): + with open(path, 'rb') as f: + return f.read() + return None + def assertEventually(self, condition, message=None, timeout=50): '''Assert that condition function eventually returns True. @@ -370,9 +375,7 @@ class Tests(dbusmock.DBusTestCase): obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock') contents = None - with open(os.path.join(dir1, "energy_performance_preference"), 'rb') as f: - contents = f.read() - self.assertEqual(contents, b'balance_power') + self.assertEventually(lambda: self.read_file(os.path.join(dir1, "energy_performance_preference")) == b'balance_power') self.stop_daemon()