integrate pytest with setup.py

This commit is contained in:
Randall Leeds 2012-10-26 14:06:29 -07:00
parent 674c1ac802
commit 1505e29248
2 changed files with 32 additions and 4 deletions

View File

@ -4,10 +4,10 @@ build:
bin/pip install -r requirements_dev.txt bin/pip install -r requirements_dev.txt
test: test:
./bin/py.test tests/ bin/python setup.py test
coverage: coverage:
./bin/py.test --cov gunicorn tests/ bin/python setup.py test --cov
clean: clean:
@rm -rf .Python bin lib include man build html @rm -rf .Python bin lib include man build html

View File

@ -5,7 +5,7 @@
import os import os
from setuptools import setup, find_packages from setuptools import setup, find_packages, Command
import sys import sys
from gunicorn import __version__ from gunicorn import __version__
@ -34,6 +34,31 @@ CLASSIFIERS = [
with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f: with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
long_description = f.read() long_description = f.read()
# read dev requirements
fname = os.path.join(os.path.dirname(__file__), 'requirements_dev.txt')
with open(fname) as f:
tests_require = list(map(lambda l: l.strip(), f.readlines()))
class PyTest(Command):
user_options = [
("cov", None, "measure coverage")
]
def initialize_options(self):
self.cov = None
def finalize_options(self):
pass
def run(self):
import sys,subprocess
basecmd = [sys.executable, '-m', 'py.test']
if self.cov:
basecmd += ['--cov', 'gunicorn']
errno = subprocess.call(basecmd + ['tests'])
raise SystemExit(errno)
setup( setup(
name = 'gunicorn', name = 'gunicorn',
version = __version__, version = __version__,
@ -50,6 +75,9 @@ setup(
packages = find_packages(exclude=['examples', 'tests']), packages = find_packages(exclude=['examples', 'tests']),
include_package_data = True, include_package_data = True,
tests_require = tests_require,
cmdclass = {'test': PyTest},
entry_points=""" entry_points="""
[console_scripts] [console_scripts]