Commits

Andy Mikhailenko committed 5190e05

Fix #38: tests that pass on source tree would fail in the package

Some files were missing; had to add them to the manifest.
Added py.test as a requirement for tests.
Added a verbose list of supported Python versions.

Comments (0)

Files changed (3)

+# needed for `python setup.py test`
+include test/__init__.py
+include test/base.py

setup.cfg

-[upload_sphinx]
-upload-dir = build/sphinx/html
-[nosetests]
-with-coverage=1
-cover-html=1
-cover-package=argh
-cover-erase=1
-rednose=1
 
 import io
 import os
+import sys
 
-# Why distutils?
-#
-# We could bundle distribute_setup.py and call it as recommended:
-#   http://packages.python.org/distribute/using.html
-# However, `distribute` seems to break PyPy (at least 1.6 thru 1.9).
-# So we'll simply fall back to plain distutils.
-try:
-    from setuptools import setup
-except:
-    from distutils.core import setup
+from setuptools import setup
+from setuptools.command.test import test as TestCommand
+
 
 # Importing `__version__` from `argh` would trigger a cascading import
 # of `argparse`. We need to avoid this as Python < 2.7 ships without argparse.
 	readme = f.read()
 
 
+class PyTest(TestCommand):
+    # see http://pytest.org/latest/goodpractises.html#integration-with-setuptools-distribute-test-commands
+
+    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.test_args)
+        sys.exit(errno)
+
+
 setup(
     # overview
     name             = 'argh',
     requires = ['python(>=2.6)', 'argparse(>=1.1)'],
     install_requires = ['argparse>=1.1'],    # for Python 2.6 (no bundled argparse; setuptools is likely to exist)
 
+    # testing
+    tests_require=['pytest'],
+    cmdclass = {'test': PyTest},
+
     # copyright
     author   = 'Andrey Mikhaylenko',
     author_email = 'neithere@gmail.com',
         'Intended Audience :: Information Technology',
         'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
         'Programming Language :: Python',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: Implementation :: CPython',
+        'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Software Development :: User Interfaces',
         'Topic :: Software Development :: Libraries :: Python Modules',
     ],