tests: find out test modules automatically
This commit is contained in:
parent
74a1fdab60
commit
19c9a895d5
@ -31,23 +31,26 @@ These tests are run automatically with 'setup.py test', but can also be run
|
|||||||
manually.
|
manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from os import listdir
|
||||||
|
from os.path import dirname
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
names = ['blob', 'commit', 'config', 'diff', 'index', 'note', 'oid', 'refs',
|
|
||||||
'remote', 'repository', 'revwalk', 'signature', 'status', 'tag',
|
|
||||||
'tree', 'treebuilder']
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
# Sometimes importing pygit2 fails, we try this first to get an
|
# Sometimes importing pygit2 fails, we try this first to get an
|
||||||
# informative traceback.
|
# informative traceback.
|
||||||
import pygit2
|
import pygit2
|
||||||
# Check the test modules import correctly, to get a nice error if one
|
|
||||||
# does not.
|
# Build the list of modules
|
||||||
modules = ['test.test_%s' % n for n in names]
|
modules = []
|
||||||
for module in modules:
|
for name in listdir(dirname(__file__)):
|
||||||
__import__(module)
|
if name.startswith('test_') and name.endswith('.py'):
|
||||||
|
module = 'test.%s' % name[:-3]
|
||||||
|
# Check the module imports correctly, have a nice error otherwise
|
||||||
|
__import__(module)
|
||||||
|
modules.append(module)
|
||||||
|
|
||||||
# Go
|
# Go
|
||||||
return unittest.defaultTestLoader.loadTestsFromNames(modules)
|
return unittest.defaultTestLoader.loadTestsFromNames(modules)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user