From 3f63133b7c39c78becf866b7b48e8059ad1a6009 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Thu, 24 Apr 2014 21:36:03 +0200 Subject: [PATCH] Parallelized tests using pytest-xdist. --- CONTRIBUTING.rst | 13 ++++++++++--- requirements-dev.txt | 1 + setup.py | 5 ++++- tox.ini | 27 ++++++++++++++++++--------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index bdf5903c..ae58572b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -63,15 +63,22 @@ HTTPie uses `pytest`_ and `Tox`_. .. code-block:: bash - # Run all tests on the current Python: + ### Running all tests: + + # Current Python python setup.py test - # Run all tests on all installed supported Pythons: + # All the supported and available Pythons tox - # Run specific tests: + ### Running specific tests: + + # Current Python pytest tests/test_uploads.py + # All Pythons + tox -- tests/test_uploads.py --verbose + Don't forget to add yourself to `AUTHORS.rst`_. diff --git a/requirements-dev.txt b/requirements-dev.txt index 9e5e31fa..7000c7e6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ tox pytest +pytest-xdist docutils diff --git a/setup.py b/setup.py index 0c479d1c..6231f8a5 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,9 @@ class PyTest(TestCommand): self.test_suite = True self.test_args = [ '--doctest-modules', - './httpie', './tests' + '-n', '8', + './httpie', + './tests' ] self.test_suite = True @@ -23,6 +25,7 @@ class PyTest(TestCommand): tests_require = [ 'pytest', + 'pytest-xdist', ] diff --git a/tox.ini b/tox.ini index eb160fc1..debfc9cc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,26 @@ # Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. +# in multiple virtualenvs. +# Run: +# $ pip install -r requirements-dev.txt +# $ tox + [tox] envlist = py26, py27, py34, pypy +usedevelop = True +skipsdist = True + [testenv] -commands = {envpython} setup.py test +whitelist_externals = + py.test + +commands = + py.test --doctest-modules \ + --basetemp={envtmpdir} \ + -n 8 \ + {posargs:./tests ./httpie} [testenv:py26] -deps = argparse - -[testenv:py27] -# Install docutils to test .rst files syntax -deps = docutils +deps = + argparse