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
1=== modified file 'lib/canonical/launchpad/utilities/ftests/test_gpghandler.py'
2--- lib/canonical/launchpad/utilities/ftests/test_gpghandler.py 2011-08-28 07:29:11 +0000
3+++ lib/canonical/launchpad/utilities/ftests/test_gpghandler.py 2011-10-27 01:02:25 +0000
4@@ -14,6 +14,11 @@
5 from zope.component import getUtility
6 from zope.security.proxy import removeSecurityProxy
7
8+from testtools.matchers import (
9+ Not,
10+ LessThan,
11+ )
12+
13 from canonical.launchpad.ftests import (
14 ANONYMOUS,
15 keys_for_tests,
16@@ -170,7 +175,9 @@
17 now = floor(time())
18 gpghandler.touchConfigurationDirectory()
19 for fname in files_to_check:
20- self.assertTrue(now <= floor(os.path.getmtime(fname)))
21+ file_time = os.path.getmtime(fname)
22+ self.assertThat(
23+ file_time, Not(LessThan(now)), fname)
24
25 def test_retrieveKey_raises_GPGKeyDoesNotExistOnServer(self):
26 # GPGHandler.retrieveKey() raises GPGKeyDoesNotExistOnServer