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:
96a8c02d24 (r54773831)
This commit is contained in:
Bastien Nocera 2021-09-06 14:28:25 +02:00
parent 93ec31e973
commit e1819c42fb
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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)