From 5ddda8f895c5de678fd3bbb1ed948f484cfaebaa Mon Sep 17 00:00:00 2001 From: Alejandro Cabrera Date: Fri, 13 Dec 2013 11:39:37 -0500 Subject: [PATCH] feat: leaner requirements, improved tox/travis support This patch reorganizes the requirements to install only what's necessary for using httpretty. This greatly reduces installation time when being pulled in as a dependency for another project. The dependencies needed for running the test suite were moved to test-requirements.txt, and were commented to indicate what type of testing dependency it it. Requirements are read in using a refactored variant of test_requirements(). The tox file and the travis yaml have been updated to reflect the changes in the requirements files. Finally, .travis.yaml has leveled up. It now supports running the test suite using pypy and python 3.3, with the added benefit that a build will still be marked as successful even if py3.3 and pypy fail. --- .travis.yml | 10 +++++++++- MANIFEST.in | 1 + requirements.txt | 8 -------- setup.py | 18 +++++++++--------- test-requirements.txt | 12 ++++++++++++ tox.ini | 3 ++- 6 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 test-requirements.txt diff --git a/.travis.yml b/.travis.yml index a4168b2..88c5228 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,20 @@ language: python python: - "2.6" - "2.7" + - "3.3" + - "pypy" + +matrix: + allow_failures: + - python: "3.3" + - python: "pypy" + env: - TEST_TYPE=unit - TEST_TYPE=functional install: - - pip install -r requirements.txt + - pip install -r requirements.txt -r test-requirements.txt script: - make $TEST_TYPE diff --git a/MANIFEST.in b/MANIFEST.in index 51eb4ef..36cedbf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include requirements.txt +include test-requirements.txt include dev-requirements.txt recursive-include tests *.py include tests/functional/fixtures/playback-*.json diff --git a/requirements.txt b/requirements.txt index 95ad370..a42590b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1 @@ -coverage -httplib2 -mock -nose -requests -tornado -tox -sure urllib3 diff --git a/setup.py b/setup.py index 06f2eb1..ae66ec3 100755 --- a/setup.py +++ b/setup.py @@ -35,13 +35,13 @@ HTTPretty.disable() HTTPRETTY_PATH = os.path.abspath(os.path.join(__file__, os.pardir)) -def test_packages(): - test_reqs = os.path.join(HTTPRETTY_PATH, 'requirements.txt') - tests_require = [ - line.strip() for line in open(test_reqs).readlines() - if not line.startswith("#") - ] - return tests_require +def parse_requirements(reqs_path): + target_path = os.path.join(HTTPRETTY_PATH, reqs_path) + return [ + line.strip() for line in open(target_path).readlines() + if not line.startswith("#") + ] + setup(name='httpretty', version=version, @@ -51,8 +51,8 @@ setup(name='httpretty', url='http://github.com/gabrielfalcao/httpretty', zip_safe=False, packages=['httpretty'], - tests_require=test_packages(), - install_requires=['urllib3'], + tests_require=parse_requirements('test-requirements.txt'), + install_requires=parse_requirements('requirements.txt'), license='MIT', test_suite='nose.collector', classifiers=["Intended Audience :: Developers", diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..92e199e --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,12 @@ +# test runner +coverage +nose + +# testing utilities +mock +sure + +# external frameworks tested against +httplib2 +requests +tornado diff --git a/tox.ini b/tox.ini index f2a8bce..0af13f8 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,8 @@ envlist = py26, py27 [testenv] -deps = -r{toxinidir}/requirements.txt +deps = -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt commands = nosetests -s tests/unit [testenv:functional]