From 625fe2cc3bd5050ba725aeb5f9433f085dab9f79 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Fri, 8 Nov 2013 17:43:30 -0500 Subject: [PATCH] Added test coverage and monkey patch to requests' json module when ujson's available --- .coveragerc | 12 ++++++++++++ .travis.yml | 2 +- foursquare/__init__.py | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..294e07b --- /dev/null +++ b/.coveragerc @@ -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 diff --git a/.travis.yml b/.travis.yml index 90c2faf..30126da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: install: - pip install . --use-mirrors -script: nosetests +script: nosetests --with-coverage --cover-package=foursquare env: global: diff --git a/foursquare/__init__.py b/foursquare/__init__.py index 1d9bc49..c7a0565 100644 --- a/foursquare/__init__.py +++ b/foursquare/__init__.py @@ -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 @@ -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