2
Utility functions for testing.
5
from unittest import TestCase
6
from StringIO import StringIO
8
def importModule(name):
10
components = name.split('.')
11
for comp in components[1:]:
12
mod = getattr(mod, comp)
15
def fileIsTest(path, skipFiles=[]):
16
if not os.path.isfile(path):
18
filename = os.path.basename(path)
19
if filename in skipFiles:
21
if filename.startswith('test') and filename.endswith('.py'):
24
def find(start, func, skip=[]):
25
for item in [os.path.join(start, x) for x in os.listdir(start)]:
28
if os.path.isdir(item):
29
for subItem in find(item, func, skip):
32
def findTests(startDir, skipFiles=[]):
33
return find(startDir, fileIsTest, skipFiles)