From: Mike Bayer Date: Thu, 16 Jul 2015 21:05:05 +0000 (-0400) Subject: - The default test runner via "python setup.py test" is now py.test. X-Git-Tag: rel_0_8_0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96214629cdb13f1694831f36c48a7ec86dd8c7f6;p=thirdparty%2Fsqlalchemy%2Falembic.git - The default test runner via "python setup.py test" is now py.test. nose still works via run_tests.py. --- diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index 8232c47d..691402d4 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -6,6 +6,12 @@ Changelog .. changelog:: :version: 0.8.0 + .. change:: + :tags: feature, tests + + The default test runner via "python setup.py test" is now py.test. + nose still works via run_tests.py. + .. change:: :tags: feature, operations :tickets: 302 diff --git a/setup.py b/setup.py index 932f2174..9cfd8c3d 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ from setuptools import setup, find_packages +from setuptools.command.test import test as TestCommand import os import re +import sys v = open(os.path.join(os.path.dirname(__file__), 'alembic', '__init__.py')) @@ -15,20 +17,31 @@ requires = [ 'Mako', ] -# Hack to prevent "TypeError: 'NoneType' object is not callable" error -# in multiprocessing/util.py _exit_function when running `python -# setup.py test` (see -# http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html) -try: - import multiprocessing -except ImportError: - pass - try: import argparse except ImportError: requires.append('argparse') + +class PyTest(TestCommand): + user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] + + def initialize_options(self): + TestCommand.initialize_options(self) + self.pytest_args = [] + + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + + def run_tests(self): + # import here, cause outside the eggs aren't loaded + import pytest + errno = pytest.main(self.pytest_args) + sys.exit(errno) + + setup(name='alembic', version=VERSION, description="A database migration tool for SQLAlchemy.", @@ -50,8 +63,8 @@ setup(name='alembic', license='MIT', packages=find_packages('.', exclude=['examples*', 'test*']), include_package_data=True, - tests_require=['nose >= 0.11', 'mock'], - test_suite="alembic.testing.runner.setup_py_test", + tests_require=['pytest', 'pytest-cov', 'mock', 'Mako'], + cmdclass={'test': PyTest}, zip_safe=False, install_requires=requires, entry_points={