Merge lp:~james-w/python-oops-wsgi/start_response-exc_info into lp:python-oops-wsgi

Proposed by James Westby
Status: Merged
Merged at revision: 35
Proposed branch: lp:~james-w/python-oops-wsgi/start_response-exc_info
Merge into: lp:python-oops-wsgi
Diff against target: 47 lines (+18/-1)
2 files modified
oops_wsgi/middleware.py (+1/-1)
oops_wsgi/tests/test_middleware.py (+17/-0)
To merge this branch: bzr merge lp:~james-w/python-oops-wsgi/start_response-exc_info
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Fixing
Review via email: mp+90031@code.launchpad.net

Description of the change

Hi,

As discussed exc_info shouldn't be passed as a keyword argument.

Thanks,

James

To post a comment you must log in.
36. By James Westby

Add the bug reference.

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

35 + step = iterator.next()
36 + # the client pipe is closed or something - we discard the iterator
37 + del iterator
38 + gc.collect()
39 + return step

I think this is more complex than needed - a simple list() should do the trick; you probably want an assert on the content of the collected calls as well(e.g. nothing demonstrates that exc_info *was* supplied).

matchers.MatchesException(ValueError('Boom, yo')) will probably be an aid there.

Oh, and there is a typo in the test function name

review: Needs Fixing
Revision history for this message
James Westby (james-w) wrote :

Hi,

I think I have addressed your comments now.

Thanks,

James

37. By James Westby

Fixes from review. Thanks Rob.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'oops_wsgi/middleware.py'
2--- oops_wsgi/middleware.py 2011-12-09 04:06:45 +0000
3+++ oops_wsgi/middleware.py 2012-01-25 03:04:24 +0000
4@@ -193,7 +193,7 @@
5 headers = [('Content-Type', content_type)]
6 headers.append(('X-Oops-Id', str(report['id'])))
7 start_response(
8- '500 Internal Server Error', headers, exc_info=exc_info)
9+ '500 Internal Server Error', headers, exc_info)
10 del exc_info
11 if error_render is not None:
12 return error_render(report)
13
14=== modified file 'oops_wsgi/tests/test_middleware.py'
15--- oops_wsgi/tests/test_middleware.py 2011-12-09 04:06:45 +0000
16+++ oops_wsgi/tests/test_middleware.py 2012-01-25 03:04:24 +0000
17@@ -31,6 +31,7 @@
18 from testtools.matchers import (
19 DocTestMatches,
20 Equals,
21+ MatchesException,
22 MatchesListwise,
23 Mismatch,
24 MismatchesAll,
25@@ -544,6 +545,22 @@
26 Equals(expected_start_response),
27 ]))
28
29+ def test_calls_start_response_with_positional_exc_info(self):
30+ def myapp(environ, start_response):
31+ raise ValueError('boom, yo')
32+ config = self.config_for_oopsing(capture_create=True)
33+ app = make_app(myapp, config)
34+ environ = self.make_outer_environ()
35+ def start_response(*args, **kwargs):
36+ if kwargs:
37+ raise AssertionError(
38+ "start_response takes no kwargs: %s" % str(kwargs))
39+ return self.calls.append
40+ list(app(environ, start_response))
41+ self.assertEqual(2, len(self.calls))
42+ self.assertThat(self.calls[0]['exc_info'],
43+ MatchesException(ValueError('boom, yo')))
44+ self.assertThat(self.calls[1], MatchesOOPS({'value': 'boom, yo'}))
45
46
47 class TestGeneratorTracker(TestCase):

Subscribers

People subscribed via source and target branches

to all changes: