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
1=== modified file 'Makefile'
2--- Makefile 2014-10-22 22:18:38 +0000
3+++ Makefile 2014-10-24 15:40:33 +0000
4@@ -16,4 +16,6 @@
5 $(BIN)/pyflakes requestsplus
6 $(BIN)/pep8 requestsplus
7
8-.PHONY: deps test
9+check: lint test
10+
11+.PHONY: deps test lint check
12
13=== modified file 'requestsplus/__init__.py'
14--- requestsplus/__init__.py 2014-10-24 13:47:18 +0000
15+++ requestsplus/__init__.py 2014-10-24 15:40:33 +0000
16@@ -110,8 +110,8 @@
17
18 @contextmanager
19 def maybe_timeline(factory, category, detail):
20- if factory is not None:
21- timeline = factory()
22+ timeline = factory() if factory is not None else None
23+ if timeline is not None:
24 action = timeline.start(category, detail)
25 try:
26 yield action
27
28=== modified file 'requestsplus/tests/__init__.py'
29--- requestsplus/tests/__init__.py 2014-10-24 13:47:18 +0000
30+++ requestsplus/tests/__init__.py 2014-10-24 15:40:33 +0000
31@@ -16,6 +16,7 @@
32 get_extra_details,
33 get_oops_ids,
34 get_request_id,
35+ maybe_timeline,
36 record_stats,
37 Session,
38 )
39@@ -302,3 +303,29 @@
40 with responses:
41 s.get(url)
42 self.assertEqual(4, len(statsd.timings))
43+
44+
45+class MaybeTimelineTests(TestCase):
46+
47+ def test_no_factory(self):
48+ with maybe_timeline(None, 'a', 'b') as action:
49+ self.assertIs(None, action)
50+
51+ def test_no_timeline(self):
52+ def factory():
53+ return None
54+ with maybe_timeline(factory, 'a', 'b') as action:
55+ self.assertIs(None, action)
56+
57+ def test_with_timeline(self):
58+ timeline = Timeline()
59+
60+ def factory():
61+ return timeline
62+
63+ with maybe_timeline(factory, 'a', 'b') as action:
64+ self.assertIsNot(None, action)
65+ self.assertEqual(1, len(timeline.actions))
66+ action = timeline.actions[0]
67+ self.assertEqual('a', action.category)
68+ self.assertEqual('b', action.detail)

Subscribers

People subscribed via source and target branches