From f5a5e6d441dc35e8dd5926f9a20e537963587d78 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Sun, 4 Dec 2016 02:24:10 -0500 Subject: [PATCH] ENH: Add support for "python setup.py test" --- circle.yml | 6 ++---- setup.cfg | 4 ++++ setup.py | 29 ++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/circle.yml b/circle.yml index ac538823..16f28003 100644 --- a/circle.yml +++ b/circle.yml @@ -5,7 +5,5 @@ dependencies: test: override: - pip install . - - | - cd ../ - nosetests --with-xunit --logging-level=DEBUG --verbosity=3 pyradiomics/tests/test_features.py pyradiomics/tests/test_cmatrices.py - cp nosetests.xml $CIRCLE_TEST_REPORTS + - python setup.py test --args="--with-xunit --logging-level=DEBUG" + - cp nosetests.xml $CIRCLE_TEST_REPORTS diff --git a/setup.cfg b/setup.cfg index 8b9bc4be..53403a62 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,7 @@ +[nosetests] +verbosity=3 +where=tests + [versioneer] VCS = git versionfile_source = radiomics/_version.py diff --git a/setup.py b/setup.py index 127cad83..eaf36ffb 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ import versioneer +from setuptools.command.test import test as TestCommand from skbuild import setup with open('requirements.txt', 'r') as fp: @@ -10,6 +11,31 @@ with open('requirements-dev.txt', 'r') as fp: dev_requirements = list(filter(bool, (line.strip() for line in fp))) +class NoseTestCommand(TestCommand): + """Command to run unit tests using nose driver after in-place build""" + + user_options = TestCommand.user_options + [ + ("args=", None, "Arguments to pass to nose"), + ] + + def initialize_options(self): + self.args = [] + TestCommand.initialize_options(self) + + def finalize_options(self): + TestCommand.finalize_options(self) + if self.args: + self.args = __import__('shlex').split(self.args) + + def run_tests(self): + # Run nose ensuring that argv simulates running nosetests directly + nose_args = ['nosetests'] + nose_args.extend(self.args) + __import__('nose').run_exit(argv=nose_args) + +commands = versioneer.get_cmdclass() +commands['test'] = NoseTestCommand + setup_requires = [] setup( @@ -21,7 +47,7 @@ author_email='pyradiomics@googlegroups.com', version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), + cmdclass=commands, packages=['radiomics'], zip_safe=False, @@ -47,5 +73,6 @@ install_requires=requirements, setup_requires=setup_requires, + test_suite='nose.collector', tests_require=dev_requirements, )