Skip to content

Commit

Permalink
Add "python setup.py test" option (fixes numenta#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaganBolliger committed Dec 9, 2015
1 parent b84021a commit 8be99cb
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion bindings/py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import tempfile

from setuptools import Command, find_packages, setup
from setuptools.command.test import test as BaseTestCommand


PY_BINDINGS = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.abspath(os.path.join(PY_BINDINGS, os.pardir, os.pardir))
Expand Down Expand Up @@ -92,6 +94,33 @@ def findRequirements(platform):



class TestCommand(BaseTestCommand):
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]


def initialize_options(self):
BaseTestCommand.initialize_options(self)
self.pytest_args = [] # pylint: disable=W0201


def finalize_options(self):
BaseTestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True


def run_tests(self):
import pytest
cwd = os.getcwd()
try:
os.chdir("tests")
errno = pytest.main(self.pytest_args)
finally:
os.chdir(cwd)
sys.exit(errno)



def getPlatformInfo():
"""Identify platform."""
if "linux" in sys.platform:
Expand Down Expand Up @@ -181,7 +210,10 @@ def generateExtensions():
},
extras_require = {"capnp": ["pycapnp==0.5.5"]},
zip_safe=False,
cmdclass={"clean": CleanCommand},
cmdclass={
"clean": CleanCommand,
"test": TestCommand,
},
description="Numenta Platform for Intelligent Computing - bindings",
author="Numenta",
author_email="help@numenta.org",
Expand Down

0 comments on commit 8be99cb

Please sign in to comment.