* Unittests are accessible to distutils now: python setup.py test
* Optionally setup virtualenv to install test dependencies using 'virtualenv'
target
---
Makefile | 12 +++++++++---
setup.py | 14 ++++++++++++--
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index a1e557b..d4529ee 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
VERSION = $(shell egrep "^VERSION" setup.py | awk '{print $$3}')
+VENV_DIR = tests/.venv
sdist:
python setup.py sdist
@@ -27,12 +28,17 @@ man2html:
@echo "Generating oz-cleanup-cache HTML page from man"
@groff -mandoc man/oz-cleanup-cache.1 -T html > man/oz-cleanup-cache.html
+$(VENV_DIR):
+ @virtualenv $(VENV_DIR)
+ @pip-python -E $(VENV_DIR) install pytest
+virtualenv: $(VENV_DIR)
+
unittests:
- @cd tests/tdl ; ./run_test
- @cd tests/factory ; ./run_test
+ @[ -f $(VENV_DIR)/bin/activate ] && source $(VENV_DIR)/bin/activate ; python
setup.py test
+ @(type deactivate 2>/dev/null | grep -q 'function') && deactivate ||
true
pylint:
pylint --rcfile=pylint.conf oz oz-install oz-customize oz-cleanup-cache
oz-generate-icicle
clean:
- rm -rf MANIFEST build dist usr *~ oz.spec *.pyc oz/*~ oz/*.pyc examples/*~ oz/auto/*~
man/*~ docs/*~ man/*.html tests/tdl/*~ tests/factory/*~
+ rm -rf MANIFEST build dist usr *~ oz.spec *.pyc oz/*~ oz/*.pyc examples/*~ oz/auto/*~
man/*~ docs/*~ man/*.html $(VENV_DIR) tests/tdl/*~ tests/factory/*~
diff --git a/setup.py b/setup.py
index 086aaa5..f120bc9 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-from distutils.core import setup, Extension
+from distutils.core import setup, Extension, Command
from distutils.command.sdist import sdist as _sdist
import os
@@ -19,6 +19,15 @@ class sdist(_sdist):
_sdist.run(self)
+class pytest(Command):
+ user_options = []
+ def initialize_options(self): pass
+ def finalize_options(self): pass
+ def run(self):
+ import subprocess
+ errno = subprocess.call('py.test tests --verbose --tb=short
--junitxml=tests/results.xml'.split())
+ raise SystemExit(errno)
+
setup(name='oz',
version=VERSION,
description='Oz automated installer',
@@ -31,6 +40,7 @@ setup(name='oz',
packages=['oz'],
scripts=['oz-install', 'oz-generate-icicle',
'oz-customize',
'oz-cleanup-cache'],
- cmdclass={'sdist': sdist},
+ cmdclass={'sdist': sdist,
+ 'test' : pytest },
data_files = datafiles,
)
--
1.7.6.2