From ff0dd1e000eb4a1552bf59dcdb78db1bd3708721 Mon Sep 17 00:00:00 2001 From: koobs Date: Mon, 24 Feb 2014 21:55:04 +1100 Subject: Integrate py.test enabling `python setup.py test` Integrate py.test according to: https://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands Enables use of standard python setup.py test command. Very handy for OS packagers & porters for QA, in this case the FreeBSD Port for cryptography which just landed. --- setup.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index a2a75504..ecf0f5ea 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ import os from distutils.command.build import build from setuptools import setup, find_packages - +from setuptools.command.test import test as TestCommand base_dir = os.path.dirname(__file__) @@ -31,6 +31,12 @@ requirements = [ SIX_DEPENDENCY ] +test_requirements = [ + "pytest", + "pretend", + "iso8601" +] + class CFFIBuild(build): """ @@ -63,6 +69,17 @@ class CFFIBuild(build): build.finalize_options(self) +class PyTest(TestCommand): + 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) + with open(os.path.join(base_dir, "README.rst")) as f: long_description = f.read() @@ -105,11 +122,13 @@ setup( install_requires=requirements, setup_requires=requirements, + tests_require=test_requirements, # for cffi zip_safe=False, ext_package="cryptography", cmdclass={ "build": CFFIBuild, + "test": PyTest, } ) -- cgit v1.2.3