]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- The default test runner via "python setup.py test" is now py.test.
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 16 Jul 2015 21:05:05 +0000 (17:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 16 Jul 2015 21:05:05 +0000 (17:05 -0400)
nose still works via run_tests.py.

docs/build/changelog.rst
setup.py

index 8232c47dcbaa2010920628fb7adce969420386bc..691402d404c5c7c8ec5509e94eac870f34f682be 100644 (file)
@@ -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
index 932f217406fe74c6002678205e182370f5ae1df3..9cfd8c3d38d255397576624540a98506e5e979f5 100644 (file)
--- 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={