Skip to content

Commit

Permalink
ENH: Add support for "python setup.py test"
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr authored and JoostJM committed Dec 21, 2016
1 parent 7da5b76 commit f5a5e6d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
6 changes: 2 additions & 4 deletions circle.yml
Expand Up @@ -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
4 changes: 4 additions & 0 deletions setup.cfg
@@ -1,3 +1,7 @@
[nosetests]
verbosity=3
where=tests

[versioneer]
VCS = git
versionfile_source = radiomics/_version.py
Expand Down
29 changes: 28 additions & 1 deletion setup.py
Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -21,7 +47,7 @@
author_email='pyradiomics@googlegroups.com',

version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
cmdclass=commands,

packages=['radiomics'],
zip_safe=False,
Expand All @@ -47,5 +73,6 @@

install_requires=requirements,
setup_requires=setup_requires,
test_suite='nose.collector',
tests_require=dev_requirements,
)

0 comments on commit f5a5e6d

Please sign in to comment.