Merge lp:~jml/launchpad/failing-tests-bug-711209 into lp:launchpad

Proposed by Jonathan Lange
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 12294
Proposed branch: lp:~jml/launchpad/failing-tests-bug-711209
Merge into: lp:launchpad
Diff against target: 81 lines (+15/-11)
2 files modified
lib/canonical/testing/layers.py (+15/-4)
lib/lp/testing/__init__.py (+0/-7)
To merge this branch: bzr merge lp:~jml/launchpad/failing-tests-bug-711209
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+48184@code.launchpad.net

Commit message

[r=sinzui][ui=none][bug=711209] Twisted tests no longer fail silently

Description of the change

This branch address bug 711209. Some Twisted tests in our suite were not failing when they ought to have been failing. This was because of a band-aid to solve a very similar problem, that turned out to be self-defeating once we were running tests without the underlying wound. i.e. the bandaid helps Trial tests, but not testtools Twisted tests.

The branch "solves" this problem by moving the bandaid into the TwistedLayer, which is only used for Trial tests. It has the pleasant side-effect of removing an import side-effect.

I verified that the fix works by adding a failing test to test_builder.py and watching it fail.

Note that fixing this bug might expose other tests that have been failing silently. Best thing to do is try to land this then watch the failures that come back from the server.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you for providing this. I learn something about zope's frame introspection too.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/testing/layers.py'
--- lib/canonical/testing/layers.py 2011-01-28 19:28:40 +0000
+++ lib/canonical/testing/layers.py 2011-02-01 16:03:56 +0000
@@ -56,7 +56,6 @@
56import gc56import gc
57import logging57import logging
58import os58import os
59import shutil
60import signal59import signal
61import socket60import socket
62import subprocess61import subprocess
@@ -69,7 +68,10 @@
69from unittest import TestCase, TestResult68from unittest import TestCase, TestResult
70from urllib import urlopen69from urllib import urlopen
7170
72from fixtures import Fixture71from fixtures import (
72 Fixture,
73 MonkeyPatch,
74 )
73import psycopg275import psycopg2
74from storm.zope.interfaces import IZStorm76from storm.zope.interfaces import IZStorm
75import transaction77import transaction
@@ -595,8 +597,8 @@
595 time.sleep(0.1)597 time.sleep(0.1)
596598
597 # Store the pidfile for other processes to kill.599 # Store the pidfile for other processes to kill.
598 pidfile = MemcachedLayer.getPidFile()600 pid_file = MemcachedLayer.getPidFile()
599 open(pidfile, 'w').write(str(MemcachedLayer._memcached_process.pid))601 open(pid_file, 'w').write(str(MemcachedLayer._memcached_process.pid))
600602
601 @classmethod603 @classmethod
602 @profiled604 @profiled
@@ -1219,6 +1221,14 @@
1219 TwistedLayer._save_signals()1221 TwistedLayer._save_signals()
1220 from twisted.internet import interfaces, reactor1222 from twisted.internet import interfaces, reactor
1221 from twisted.python import threadpool1223 from twisted.python import threadpool
1224 # zope.exception demands more of frame objects than
1225 # twisted.python.failure provides in its fake frames. This is enough
1226 # to make it work with them as of 2009-09-16. See
1227 # https://bugs.launchpad.net/bugs/425113.
1228 cls._patch = MonkeyPatch(
1229 'twisted.python.failure._Frame.f_locals',
1230 property(lambda self: {}))
1231 cls._patch.setUp()
1222 if interfaces.IReactorThreads.providedBy(reactor):1232 if interfaces.IReactorThreads.providedBy(reactor):
1223 pool = getattr(reactor, 'threadpool', None)1233 pool = getattr(reactor, 'threadpool', None)
1224 # If the Twisted threadpool has been obliterated (probably by1234 # If the Twisted threadpool has been obliterated (probably by
@@ -1240,6 +1250,7 @@
1240 if pool is not None:1250 if pool is not None:
1241 reactor.threadpool.stop()1251 reactor.threadpool.stop()
1242 reactor.threadpool = None1252 reactor.threadpool = None
1253 cls._patch.cleanUp()
1243 TwistedLayer._restore_signals()1254 TwistedLayer._restore_signals()
12441255
12451256
12461257
=== modified file 'lib/lp/testing/__init__.py'
--- lib/lp/testing/__init__.py 2011-01-17 22:31:30 +0000
+++ lib/lp/testing/__init__.py 2011-02-01 16:03:56 +0000
@@ -87,10 +87,6 @@
87from testtools.content import Content87from testtools.content import Content
88from testtools.content_type import UTF8_TEXT88from testtools.content_type import UTF8_TEXT
89import transaction89import transaction
90# zope.exception demands more of frame objects than twisted.python.failure
91# provides in its fake frames. This is enough to make it work with them
92# as of 2009-09-16. See https://bugs.launchpad.net/bugs/425113.
93from twisted.python.failure import _Frame
94from windmill.authoring import WindmillTestClient90from windmill.authoring import WindmillTestClient
95from zope.component import (91from zope.component import (
96 adapter,92 adapter,
@@ -163,9 +159,6 @@
163from lp.testing.matchers import Provides159from lp.testing.matchers import Provides
164160
165161
166_Frame.f_locals = property(lambda self: {})
167
168
169class FakeTime:162class FakeTime:
170 """Provides a controllable implementation of time.time().163 """Provides a controllable implementation of time.time().
171164