make test suite runnable with "setup.py test"

This commit is contained in:
Adrian Sampson 2010-07-08 11:07:56 -07:00
parent 1ccc3bd6b9
commit e834ffd44f
3 changed files with 11 additions and 2 deletions

View file

@ -30,6 +30,7 @@ setup(name='beets',
license='MIT',
platforms='ALL',
long_description=_read('README'),
test_suite='test.testall.suite',
packages=[
'beets',

2
test/__init__.py Normal file
View file

@ -0,0 +1,2 @@
# placeholder

View file

@ -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__':