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
=== modified file 'rabbitfixture/tests/test_server.py'
--- rabbitfixture/tests/test_server.py 2011-07-07 07:04:43 +0000
+++ rabbitfixture/tests/test_server.py 2011-09-16 12:11:12 +0000
@@ -16,6 +16,7 @@
16 RabbitServerResources,16 RabbitServerResources,
17 )17 )
18from testtools import TestCase18from testtools import TestCase
19from testtools.testcase import gather_details
1920
2021
21class TestRabbitFixture(TestCase):22class TestRabbitFixture(TestCase):
@@ -28,21 +29,26 @@
28 self.useFixture(EnvironmentVariableFixture('HOME', '/nonsense/value'))29 self.useFixture(EnvironmentVariableFixture('HOME', '/nonsense/value'))
2930
30 def test_start_check_shutdown(self):31 def test_start_check_shutdown(self):
31 fixture = self.useFixture(RabbitServer())32 # The fixture correctly starts and stops RabbitMQ.
3233 with RabbitServer() as fixture:
33 # We can connect.34 try:
34 connect_arguments = {35 # We can connect.
35 "host": 'localhost:%s' % fixture.config.port,36 connect_arguments = {
36 "userid": "guest", "password": "guest",37 "host": 'localhost:%s' % fixture.config.port,
37 "virtual_host": "/", "insist": False,38 "userid": "guest", "password": "guest",
38 }39 "virtual_host": "/", "insist": False,
39 amqp.Connection(**connect_arguments).close()40 }
40 # And get a log file.41 amqp.Connection(**connect_arguments).close()
41 log = fixture.runner.getDetails()["server.log"]42 # And get a log file.
42 # Which shouldn't blow up on iteration.43 log = fixture.runner.getDetails()["server.log"]
43 list(log.iter_text())44 # Which shouldn't blow up on iteration.
4445 list(log.iter_text())
45 fixture.cleanUp()46 except Exception:
47 # self.useFixture() is not being used because we want to
48 # handle the fixture's lifecycle, so we must also be
49 # responsible for propagating fixture details.
50 gather_details(fixture.getDetails(), self.getDetails())
51 raise
4652
47 # The daemon should be closed now.53 # The daemon should be closed now.
48 self.assertRaises(socket.error, amqp.Connection, **connect_arguments)54 self.assertRaises(socket.error, amqp.Connection, **connect_arguments)
4955
=== modified file 'setup.py'
--- setup.py 2011-09-09 13:49:24 +0000
+++ setup.py 2011-09-16 12:11:12 +0000
@@ -16,5 +16,5 @@
16 'amqplib >= 0.6.1',16 'amqplib >= 0.6.1',
17 'fixtures >= 0.3.6',17 'fixtures >= 0.3.6',
18 'setuptools',18 'setuptools',
19 'testtools >= 0.9.11',19 'testtools >= 0.9.12',
20 ])20 ])

Subscribers

People subscribed via source and target branches

to all changes: