Skip to content

Commit

Permalink
Added test coverage and monkey patch to requests' json module when uj…
Browse files Browse the repository at this point in the history
…son's available
  • Loading branch information
Leo Li committed Nov 8, 2013
1 parent a32923f commit 625fe2c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[run]
omit =
*/python?.?/*
*/lib-python/?.?/*.py
*/lib_pypy/_*.py
*/site-packages/ordereddict.py
*/site-packages/nose/*
*/unittest2/*

exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ python:

install:
- pip install . --use-mirrors
script: nosetests
script: nosetests --with-coverage --cover-package=foursquare

env:
global:
Expand Down
6 changes: 5 additions & 1 deletion foursquare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
# but we need to import for the version #
try:
import requests

# Monkey patch to requests' json using ujson when available;
# Otherwise it wouldn't affect anything
requests.models.json = json
except ImportError:
pass

Expand Down Expand Up @@ -769,7 +773,7 @@ def _process_response(response):
errmsg = u'Invalid response: {0}'.format(response.text())
log.error(errmsg)
raise FoursquareException(errmsg)

# Default case, Got proper response
if response.status_code == 200:
return data
Expand Down

0 comments on commit 625fe2c

Please sign in to comment.