Merge lp:~allenap/rabbitfixture/details-breakage-bug-851813 into lp:rabbitfixture

Proposed by Gavin Panella
Status: Merged
Approved by: Julian Edwards
Approved revision: 24
Merged at revision: 23
Proposed branch: lp:~allenap/rabbitfixture/details-breakage-bug-851813
Merge into: lp:rabbitfixture
Diff against target: 64 lines (+22/-16)
2 files modified
rabbitfixture/tests/test_server.py (+21/-15)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~allenap/rabbitfixture/details-breakage-bug-851813
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+75726@code.launchpad.net

Commit message

Handle the fixture lifecycle entirely in test_start_check_shutdown. Previously the fixture was torn down explicitly within the test, and the test harness later failed during clean-up when trying to access a defunct fixture detail.

Description of the change

The bug report has a description of the problem. In addition, I needed to bump up the testtools version required because of changed behaviour of gather_details() between 0.9.11 and 0.9.12.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rabbitfixture/tests/test_server.py'
2--- rabbitfixture/tests/test_server.py 2011-07-07 07:04:43 +0000
3+++ rabbitfixture/tests/test_server.py 2011-09-16 12:11:12 +0000
4@@ -16,6 +16,7 @@
5 RabbitServerResources,
6 )
7 from testtools import TestCase
8+from testtools.testcase import gather_details
9
10
11 class TestRabbitFixture(TestCase):
12@@ -28,21 +29,26 @@
13 self.useFixture(EnvironmentVariableFixture('HOME', '/nonsense/value'))
14
15 def test_start_check_shutdown(self):
16- fixture = self.useFixture(RabbitServer())
17-
18- # We can connect.
19- connect_arguments = {
20- "host": 'localhost:%s' % fixture.config.port,
21- "userid": "guest", "password": "guest",
22- "virtual_host": "/", "insist": False,
23- }
24- amqp.Connection(**connect_arguments).close()
25- # And get a log file.
26- log = fixture.runner.getDetails()["server.log"]
27- # Which shouldn't blow up on iteration.
28- list(log.iter_text())
29-
30- fixture.cleanUp()
31+ # The fixture correctly starts and stops RabbitMQ.
32+ with RabbitServer() as fixture:
33+ try:
34+ # We can connect.
35+ connect_arguments = {
36+ "host": 'localhost:%s' % fixture.config.port,
37+ "userid": "guest", "password": "guest",
38+ "virtual_host": "/", "insist": False,
39+ }
40+ amqp.Connection(**connect_arguments).close()
41+ # And get a log file.
42+ log = fixture.runner.getDetails()["server.log"]
43+ # Which shouldn't blow up on iteration.
44+ list(log.iter_text())
45+ except Exception:
46+ # self.useFixture() is not being used because we want to
47+ # handle the fixture's lifecycle, so we must also be
48+ # responsible for propagating fixture details.
49+ gather_details(fixture.getDetails(), self.getDetails())
50+ raise
51
52 # The daemon should be closed now.
53 self.assertRaises(socket.error, amqp.Connection, **connect_arguments)
54
55=== modified file 'setup.py'
56--- setup.py 2011-09-09 13:49:24 +0000
57+++ setup.py 2011-09-16 12:11:12 +0000
58@@ -16,5 +16,5 @@
59 'amqplib >= 0.6.1',
60 'fixtures >= 0.3.6',
61 'setuptools',
62- 'testtools >= 0.9.11',
63+ 'testtools >= 0.9.12',
64 ])

Subscribers

People subscribed via source and target branches

to all changes: