Add support for running tests from setup.py

Now possible to run tests with python setup.py test. Additional arguments can be passed to py.test with the '--pytest-args="opts"' flag. This commit also separates test requirements from install requirements.
This commit is contained in:
justanr committed 2015-08-05 10:30:08 -04:00
1 parent 948c6a26d0
commit 770d69b6d1
5 files changed
+37 -10

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ python:
- "3.3"
# command to install dependencies
install:
- "pip install -r requirements.txt"
- "pip install -r test_requirements.txt"
- "pip install coveralls"
# command to run tests
script:
+1
View File
@@ -10,4 +10,5 @@ contributors:
# Contributors
* CasperVg
* Alec Reiter <https://github.com/justanr>
* Feel free to join! :)
-4
View File
@@ -20,11 +20,7 @@ Jinja2==2.7.3
Mako==1.0.1
MarkupSafe==0.23
mistune==0.6
py==1.4.29
Pygments==2.0.2
pytest==2.7.2
pytest-cov==1.8.1
pytest-random==0.2
pytz==2015.4
redis==2.10.3
requests==2.7.0
+30 -5
View File
@@ -24,6 +24,27 @@ Resources
"""
from setuptools import setup
from setuptools.command.test import test as TestCommand
import sys
class PyTestCommand(TestCommand):
user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
def initialize_options(self):
super(PyTestCommand, self).initialize_options()
self.pytest_args = []
def finalize_options(self):
super(PyTestCommand, self).finalize_options()
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
setup(
name='FlaskBB',
@@ -69,10 +90,6 @@ setup(
'coverage',
'itsdangerous',
'mistune',
'py',
'pytest',
'pytest-cov',
'pytest-random',
'pytz',
'redis',
'requests',
@@ -80,6 +97,13 @@ setup(
'speaklater',
'sqlalchemy-utils'
],
test_suite='tests',
tests_require=[
'py',
'pytest',
'pytest-cov',
'pytest-random'
],
dependency_links=[
'https://github.com/jshipley/Flask-WhooshAlchemy/archive/master.zip#egg=Flask-WhooshAlchemy',
'https://github.com/sh4nks/flask-babelex/tarball/master#egg=Flask-BabelEx'
@@ -94,5 +118,6 @@ setup(
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules'
]
],
cmdclass={'test': PyTestCommand}
)
+5
View File
@@ -0,0 +1,5 @@
-r requirements.txt
py==1.4.29
pytest==2.7.2
pytest-cov==1.8.1
pytest-random==0.2