Skip to content

Commit

Permalink
Unify running unit tests under unittest2
Browse files Browse the repository at this point in the history
There are three ways to run the tests. This is unfortunate, but
with this commit they're all going through the same code paths.

* As a developer, use "python setup.py test". This runs them in
  the current development directory and does not require a
  virtualenv to be set up.

* As a contributor, your pull requests will be tested on Travis CI.
  The configuration for that is in .travis.yml. This runs the test
  suite on all supported platforms.

* As a release maintainer, install tox (in a virtualenv?) and run
  "tox" in the toplevel Park source tree to build a source
  distribution and run the test suite on supported platforms.
  • Loading branch information
pteichman committed Sep 19, 2012
1 parent ad2f5fd commit ceea6e9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ python:
- "2.6"

install: pip install -r test-requirements.txt --use-mirrors
script: python setup.py check
script:
pep8 park.py test_park.py
pyflakes park.py test_park.py
python setup.py test
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include README.rst LICENSE test_park.py
include README.rst
include LICENSE
include test_park.py
include test-requirements.txt
17 changes: 17 additions & 0 deletions README.hacking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Welcome!

There are three ways the Park unit test suite is run.

As a *developer*, use ``python setup.py test``. This runs the suite in
the current development directory and does not require a virtualenv to
be set up.

As a *contributor*, your Github pull requests will be tested on Travis
CI. The configuration for that is in .travis.yml. This runs the test
suite on all supported platforms, which are enumerated in that file.

As a *release maintainer*, install ``tox`` (in a virtualenv is fine)
and run it in the top level Park source directory. This will build a
source distribution, install that into a virtualenv for each supported
platform, and run the test suite in each.

42 changes: 8 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,16 @@
# coding: utf-8

import park
import sys

# Require setuptools. See http://pypi.python.org/pypi/setuptools for
# installation instructions, or run the ez_setup script found at
# http://peak.telecommunity.com/dist/ez_setup.py
from setuptools import setup, find_packages, Command
from setuptools import setup

class CheckCommand(Command):
description = "Run tests."
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
import subprocess

print "Running pep8..."
if subprocess.call(["pep8", "park.py", "test_park.py"]):
sys.exit("ERROR: failed pep8 checks")

print "Running pyflakes..."
if subprocess.call(["pyflakes", "park.py", "test_park.py"]):
sys.exit("ERROR: failed pyflakes checks")

print "Running tests..."
if subprocess.call(["coverage", "run", "--source=park,test_park",
"./setup.py", "test"]):
sys.exit("ERROR: failed unit tests")

subprocess.call(['coverage', 'report', '-m'])
# Load the test requirements. These are in a separate file so they can
# be accessed from Travis CI and tox.
with open("test-requirements.txt") as fd:
tests_require = list(fd.xreadlines())


setup(
Expand All @@ -47,16 +23,14 @@ def run(self):
url = "https://github.com/litl/park",
description="A key-value store with ordered traversal of keys",
py_modules=["park"],
test_suite="unittest2.collector",

cmdclass = {
"check": CheckCommand
},

setup_requires = [
"unittest2==0.5.1"
],

test_suite="unittest2.collector",
tests_require = tests_require,

classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ envlist = py26, py27

[testenv]
deps=
flake8==1.4
-r{toxinidir}/test-requirements.txt

commands=
flake8 park.py test_park.py
pep8 park.py test_park.py
pyflakes park.py test_park.py
python setup.py test

0 comments on commit ceea6e9

Please sign in to comment.