Browse files

reorganizing tests so that they run under pytest and get called by `p…

…ython setup.py test`
  • Loading branch information...
1 parent 2bba9d4 commit b402af3da4f2ecb5adcc8d68334ec29926cdba18 John R. Frank committed Feb 23, 2014
View
4 Makefile
@@ -10,8 +10,8 @@ build: clean
install: build
pip install .
-test:
- run_tests.sh
+test: clean
+ python setup.py test
register:
python setup.py sdist bdist_egg upload -r pypi
View
5 run_tests.sh
@@ -1,5 +0,0 @@
-export PYTHONPATH="."
-
-coverage run --source=pyaccumulo --omit="pyaccumulo/proxy/*" tests/core_tests.py && \
-coverage run --append --source=pyaccumulo --omit="pyaccumulo/proxy/*" tests/iterator_tests.py && \
-(coverage html --omit="pyaccumulo/proxy/*" && echo -e "\n=== Wrote html report to htmlcov/index.html ===\n" ; coverage report --omit="pyaccumulo/proxy/*")
View
32 setup.py
@@ -96,6 +96,37 @@ def run(self):
Please ask in the user forums for help.
"""
+class PyTest(Command):
+ '''run py.test'''
+
+ description = 'runs py.test to execute all tests'
+
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ cmd = ['pip', 'install']
+ if self.distribution.install_requires:
+ cmd.extend(self.distribution.install_requires)
+ if self.distribution.tests_require:
+ cmd.extend(self.distribution.tests_require)
+ errno = subprocess.call(cmd)
+ if errno:
+ raise SystemExit(errno)
+
+ # reload sys.path for any new libraries installed
+ import site
+ site.main()
+ print sys.path
+ # use pytest to run tests
+ pytest = __import__('pytest')
+ exitcode = pytest.main(['--cov', 'pyaccumulo', '--cov-report', 'term', '-vvs', 'tests'])
+ sys.exit(exitcode)
VERSION, HASH = version.get_git_version()
@@ -119,6 +150,7 @@ def run(self):
cmdclass=dict(
doc = doc,
rpm = rpm,
+ test = PyTest,
),
classifiers=[
'Development Status :: 3 - Alpha',
View
0 tests/__init__.py
No changes.
View
0 tests/core_tests.py → tests/test_core.py
File renamed without changes.
View
0 tests/iterator_tests.py → tests/test_iterator.py
File renamed without changes.

0 comments on commit b402af3

Please sign in to comment.