Merge lp:~james-w/requestsplus/fix-maybe-timeline into lp:requestsplus

Proposed by James Westby
Status: Merged
Approved by: James Westby
Approved revision: 13
Merged at revision: 12
Proposed branch: lp:~james-w/requestsplus/fix-maybe-timeline
Merge into: lp:requestsplus
Diff against target: 68 lines (+32/-3)
3 files modified
Makefile (+3/-1)
requestsplus/__init__.py (+2/-2)
requestsplus/tests/__init__.py (+27/-0)
To merge this branch: bzr merge lp:~james-w/requestsplus/fix-maybe-timeline
Reviewer Review Type Date Requested Status
Ricardo Kirkner (community) Approve
Review via email: mp+239488@code.launchpad.net

Commit message

Fix maybe_timeline for the case where the factory returns None.

To post a comment you must log in.
Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

LGTM

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (4.5 KiB)

The attempt to merge lp:~james-w/requestsplus/fix-maybe-timeline into lp:requestsplus failed. Below is the output from the failed tests.

virtualenv virtualenv
New python executable in virtualenv/bin/python
Installing setuptools, pip...done.
virtualenv/bin/pip install -r requirements.txt
Downloading/unpacking fixtures (from -r requirements.txt (line 1))
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/fixtures/setup.py) egg_info for package fixtures

    Installed /mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/fixtures/pbr-0.10.0-py2.7.egg
    [pbr] Processing SOURCES.txt
    warning: LocalManifestMaker: standard file '-c' not found

    warning: no previously-included files found matching '.gitignore'
    warning: no previously-included files found matching '.gitreview'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
Downloading/unpacking pyflakes (from -r requirements.txt (line 2))
  Downloading pyflakes-0.8.1-py2.py3-none-any.whl
Downloading/unpacking pep8 (from -r requirements.txt (line 3))
  Downloading pep8-1.5.7-py2.py3-none-any.whl
Downloading/unpacking requests (from -r requirements.txt (line 4))
Downloading/unpacking responses (from -r requirements.txt (line 5))
  Downloading responses-0.3.0.tar.gz
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/responses/setup.py) egg_info for package responses

Downloading/unpacking testtools (from -r requirements.txt (line 6))
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/testtools/setup.py) egg_info for package testtools

    no previously-included directories found matching 'doc/_build'
Downloading/unpacking timeline (from -r requirements.txt (line 7))
  Downloading timeline-0.0.4.tar.gz
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/timeline/setup.py) egg_info for package timeline

Downloading/unpacking mock (from responses->-r requirements.txt (line 5))
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/mock/setup.py) egg_info for package mock

    warning: no files found matching '*.png' under directory 'docs'
    warning: no files found matching '*.css' under directory 'docs'
    warning: no files found matching '*.html' under directory 'docs'
    warning: no files found matching '*.js' under directory 'docs'
Downloading/unpacking six (from responses->-r requirements.txt (line 5))
  Downloading six-1.8.0-py2.py3-none-any.whl
Downloading/unpacking extras (from testtools->-r requirements.txt (line 6))
  Downloading extras-0.0.3.tar.gz
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/extras/setup.py) egg_info for package extras

Downloading/unpacking python-mimeparse (from testtools->-r requirements.txt (line 6))
  Downloading python-mimeparse-0.1.4.tar.gz
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/virtualenv/build/python-mimeparse/setup.py) egg_info for package python-mimeparse

Downloading/unpacking pytz (from timeline->-r requirements.txt (line 7))
  Running setup.py (path:/mnt/tarmac/cache/requestsplus/trunk/vi...

Read more...

13. By James Westby

Fix lint.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2014-10-22 22:18:38 +0000
+++ Makefile 2014-10-24 15:40:33 +0000
@@ -16,4 +16,6 @@
16 $(BIN)/pyflakes requestsplus16 $(BIN)/pyflakes requestsplus
17 $(BIN)/pep8 requestsplus17 $(BIN)/pep8 requestsplus
1818
19.PHONY: deps test19check: lint test
20
21.PHONY: deps test lint check
2022
=== modified file 'requestsplus/__init__.py'
--- requestsplus/__init__.py 2014-10-24 13:47:18 +0000
+++ requestsplus/__init__.py 2014-10-24 15:40:33 +0000
@@ -110,8 +110,8 @@
110110
111@contextmanager111@contextmanager
112def maybe_timeline(factory, category, detail):112def maybe_timeline(factory, category, detail):
113 if factory is not None:113 timeline = factory() if factory is not None else None
114 timeline = factory()114 if timeline is not None:
115 action = timeline.start(category, detail)115 action = timeline.start(category, detail)
116 try:116 try:
117 yield action117 yield action
118118
=== modified file 'requestsplus/tests/__init__.py'
--- requestsplus/tests/__init__.py 2014-10-24 13:47:18 +0000
+++ requestsplus/tests/__init__.py 2014-10-24 15:40:33 +0000
@@ -16,6 +16,7 @@
16 get_extra_details,16 get_extra_details,
17 get_oops_ids,17 get_oops_ids,
18 get_request_id,18 get_request_id,
19 maybe_timeline,
19 record_stats,20 record_stats,
20 Session,21 Session,
21)22)
@@ -302,3 +303,29 @@
302 with responses:303 with responses:
303 s.get(url)304 s.get(url)
304 self.assertEqual(4, len(statsd.timings))305 self.assertEqual(4, len(statsd.timings))
306
307
308class MaybeTimelineTests(TestCase):
309
310 def test_no_factory(self):
311 with maybe_timeline(None, 'a', 'b') as action:
312 self.assertIs(None, action)
313
314 def test_no_timeline(self):
315 def factory():
316 return None
317 with maybe_timeline(factory, 'a', 'b') as action:
318 self.assertIs(None, action)
319
320 def test_with_timeline(self):
321 timeline = Timeline()
322
323 def factory():
324 return timeline
325
326 with maybe_timeline(factory, 'a', 'b') as action:
327 self.assertIsNot(None, action)
328 self.assertEqual(1, len(timeline.actions))
329 action = timeline.actions[0]
330 self.assertEqual('a', action.category)
331 self.assertEqual('b', action.detail)

Subscribers

People subscribed via source and target branches