From e834ffd44f028273e91aeaafa9d3191e29fb2c03 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 8 Jul 2010 11:07:56 -0700 Subject: [PATCH] make test suite runnable with "setup.py test" --- setup.py | 1 + test/__init__.py | 2 ++ test/testall.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/__init__.py diff --git a/setup.py b/setup.py index 02e028ded..33cf55e30 100755 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ setup(name='beets', license='MIT', platforms='ALL', long_description=_read('README'), + test_suite='test.testall.suite', packages=[ 'beets', diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 000000000..753712b93 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,2 @@ +# placeholder + diff --git a/test/testall.py b/test/testall.py index a6a443f01..1cabde503 100755 --- a/test/testall.py +++ b/test/testall.py @@ -17,14 +17,20 @@ import unittest import os import re +import sys + +pkgpath = os.path.dirname(__file__) +sys.path.append(pkgpath) +os.chdir(pkgpath) def suite(): s = unittest.TestSuite() # get the suite() of every module in this directory begining with test_ - for fname in os.listdir('.'): + for fname in os.listdir(pkgpath): match = re.match(r'(test_\S+)\.py$', fname) if match: - s.addTest(__import__(match.group(1)).suite()) + modname = match.group(1) + s.addTest(__import__(modname).suite()) return s if __name__ == '__main__':