Merge lp:~mbp/launchpad/882324-mtime-test into lp:launchpad

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 14198
Proposed branch: lp:~mbp/launchpad/882324-mtime-test
Merge into: lp:launchpad
Diff against target: 26 lines (+8/-1)
1 file modified
lib/canonical/launchpad/utilities/ftests/test_gpghandler.py (+8/-1)
To merge this branch: bzr merge lp:~mbp/launchpad/882324-mtime-test
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+80521@code.launchpad.net

Commit message

[r=lifeless][bug=882324] make testHomeDirectoryJob assertion more robust and fail more obviously

Description of the change

This tries to make the spurious test failure in bug 882324 either not happen, or at least fail in a more obvious way.

I can't reproduce it locally after several tries so I'm not sure this fixes it.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

That looks ok, though personally I would ditch the assertTrue for
assertThat(
    floor(os.path.getmtime(fname)), Or(LessThan(now), Equals(now)), "fname")

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

erm, \o/ on typos. Obviously I meant:
assertThat(floor(os.path.getmtime(fname)), Not(LessThan(now)), "fname")

Revision history for this message
Robert Collins (lifeless) wrote :

and without the quotes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/utilities/ftests/test_gpghandler.py'
--- lib/canonical/launchpad/utilities/ftests/test_gpghandler.py 2011-08-28 07:29:11 +0000
+++ lib/canonical/launchpad/utilities/ftests/test_gpghandler.py 2011-10-27 01:02:25 +0000
@@ -14,6 +14,11 @@
14from zope.component import getUtility14from zope.component import getUtility
15from zope.security.proxy import removeSecurityProxy15from zope.security.proxy import removeSecurityProxy
1616
17from testtools.matchers import (
18 Not,
19 LessThan,
20 )
21
17from canonical.launchpad.ftests import (22from canonical.launchpad.ftests import (
18 ANONYMOUS,23 ANONYMOUS,
19 keys_for_tests,24 keys_for_tests,
@@ -170,7 +175,9 @@
170 now = floor(time())175 now = floor(time())
171 gpghandler.touchConfigurationDirectory()176 gpghandler.touchConfigurationDirectory()
172 for fname in files_to_check:177 for fname in files_to_check:
173 self.assertTrue(now <= floor(os.path.getmtime(fname)))178 file_time = os.path.getmtime(fname)
179 self.assertThat(
180 file_time, Not(LessThan(now)), fname)
174181
175 def test_retrieveKey_raises_GPGKeyDoesNotExistOnServer(self):182 def test_retrieveKey_raises_GPGKeyDoesNotExistOnServer(self):
176 # GPGHandler.retrieveKey() raises GPGKeyDoesNotExistOnServer183 # GPGHandler.retrieveKey() raises GPGKeyDoesNotExistOnServer