From e1819c42fbfc13d74b9788256eeebb2455e162b0 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 6 Sep 2021 14:28:25 +0200 Subject: [PATCH] gio: Fix conditions in memory-monitor test We were lucky that this worked in some cases (the test is racy), but we should actually run the condition check each loop, rather than when the function is called. Spotted by Martin Pitt: https://github.com/GNOME/glib/commit/96a8c02d240d7c9ae366c63771291413384bdfb7#r54773831 --- gio/tests/memory-monitor-dbus.py.in | 4 ++-- gio/tests/memory-monitor-portal.py.in | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/tests/memory-monitor-dbus.py.in b/gio/tests/memory-monitor-dbus.py.in index e8ac28faf..bf3291847 100755 --- a/gio/tests/memory-monitor-dbus.py.in +++ b/gio/tests/memory-monitor-dbus.py.in @@ -99,11 +99,11 @@ try: self.dbusmock.EmitWarning(100) # Wait 2 seconds or until warning - self.assertEventually(self.last_warning == 100, "'100' low-memory warning not received", 20) + self.assertEventually(lambda: self.last_warning == 100, "'100' low-memory warning not received", 20) self.dbusmock.EmitWarning(255) # Wait 2 seconds or until warning - self.assertEventually(self.last_warning == 255, "'255' low-memory warning not received", 20) + self.assertEventually(lambda: self.last_warning == 255, "'255' low-memory warning not received", 20) except ImportError as e: @unittest.skip("Cannot import %s" % e.name) diff --git a/gio/tests/memory-monitor-portal.py.in b/gio/tests/memory-monitor-portal.py.in index 36d5094d3..748cee850 100755 --- a/gio/tests/memory-monitor-portal.py.in +++ b/gio/tests/memory-monitor-portal.py.in @@ -117,11 +117,11 @@ try: self.dbusmock.EmitWarning(100) # Wait 2 seconds or until warning - self.assertEventually(self.last_warning == 100, "'100' low-memory warning not received", 20) + self.assertEventually(lambda: self.last_warning == 100, "'100' low-memory warning not received", 20) self.dbusmock.EmitWarning(255) # Wait 2 seconds or until warning - self.assertEventually(self.last_warning == 255, "'255' low-memory warning not received", 20) + self.assertEventually(lambda: self.last_warning == 255, "'255' low-memory warning not received", 20) except ImportError as e: @unittest.skip("Cannot import %s" % e.name)