aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rwxr-xr-xsetup.py26
-rw-r--r--tests/__init__.py0
3 files changed, 29 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 7c59716..c2c0690 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ default:
@echo " + devbuild"
@echo " (build and) install the package to the virtualenv"
@echo " + test"
- @echo " run the test cases"
+ @echo " run the tests"
# Create virtualenv and install/update the dependencies
venv: ${VENV}/bin/activate
@@ -33,6 +33,6 @@ ${VENV}/bin/activate: requirements.txt
devbuild: venv
./${VENV}/bin/python3 setup.py install
-# Run the test cases
+# Run the tests
test: devbuild
- ./${VENV}/bin/python3 tests/runtests.py
+ ./${VENV}/bin/python3 setup.py test
diff --git a/setup.py b/setup.py
index 3d9a6d6..38b6e8d 100755
--- a/setup.py
+++ b/setup.py
@@ -1,18 +1,43 @@
#!/usr/bin/env python3
#
+# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
+# MIT license
+#
# References:
# [1] Python Packaging User Guide
# https://packaging.python.org/
+# [2] pytest - Good Integration Practices
+# http://doc.pytest.org/en/latest/goodpractices.html
#
import os
import sys
from setuptools import setup, find_packages
+from setuptools.command.test import test as TestCommand
import fg21sim as pkg
+class PyTest(TestCommand):
+ user_options = [("pytest-args=", "a", "Arguments to pass to pytest")]
+
+ def initialize_options(self):
+ TestCommand.initialize_options(self)
+ self.pytest_args = []
+
+ 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.pytest_args)
+ sys.exit(errno)
+
+
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
@@ -56,4 +81,5 @@ setup(
"configobj",
],
tests_require=["pytest"],
+ cmdclass={"test": PyTest},
)
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/__init__.py
+++ /dev/null