allow calling runtests on one test only

Original commit message from CVS:
allow calling runtests on one test only
This commit is contained in:
Thomas Vander Stichele 2005-10-05 14:22:56 +00:00
parent 16bb9b838e
commit aabc3e7be1

View file

@ -28,17 +28,21 @@ import unittest
SKIP_FILES = ['common', 'runtests'] SKIP_FILES = ['common', 'runtests']
def gettestnames(): def gettestnames(which):
dir = os.path.split(os.path.abspath(__file__))[0] if not which:
files = [os.path.basename(p) for p in glob.glob('%s/*.py' % dir)] dir = os.path.split(os.path.abspath(__file__))[0]
names = map(lambda x: x[:-3], files) which = [os.path.basename(p) for p in glob.glob('%s/*.py' % dir)]
map(names.remove, SKIP_FILES)
names = map(lambda x: x[:-3], which)
for f in SKIP_FILES:
if f in names:
names.remove(f)
return names return names
suite = unittest.TestSuite() suite = unittest.TestSuite()
loader = unittest.TestLoader() loader = unittest.TestLoader()
for name in gettestnames(): for name in gettestnames(sys.argv[1:]):
suite.addTest(loader.loadTestsFromName(name)) suite.addTest(loader.loadTestsFromName(name))
descriptions = 1 descriptions = 1