3
"""Pitivi tests runner."""
6
# This call has to be made before any "import gst" call!
7
# We have to do this call here, even though it already is in __init__.py,
8
# because this tool is run directly, as an executable.
12
def gettestnames(file_names):
13
test_names = [file_name[:-3] for file_name in file_names]
16
loader = unittest.TestLoader()
21
if 'VERBOSE' in os.environ:
24
from pitivi.log import log
25
log.init('PITIVI_DEBUG', 1)
27
# Make available to configure.py the top level dir.
28
dir = os.path.dirname(os.path.abspath(__file__))
29
top_srcdir = os.path.split(dir)[0]
30
os.environ.setdefault('PITIVI_TOP_LEVEL_DIR', top_srcdir)
32
# Pick which tests to run.
33
TEST_CASE = os.getenv("TESTCASE")
35
test_names = [TEST_CASE]
37
test_names = gettestnames(sys.argv[1:])
38
suite = loader.loadTestsFromNames(test_names)
40
raise Exception("No tests found")
43
testRunner = unittest.TextTestRunner(descriptions=descriptions,
45
result = testRunner.run(suite)
46
if result.failures or result.errors:
10
def _testcases(filenames):
11
"""Yield testcases out of filenames."""
12
for filename in filenames:
13
if filename.endswith(".py"):
18
"""Pick which tests to run."""
19
testcase = os.getenv("TESTCASE")
21
testcases = [testcase]
23
testcases = _testcases(sys.argv[1:])
24
loader = unittest.TestLoader()
25
return loader.loadTestsFromNames(testcases)
29
tests_dir = os.path.dirname(os.path.abspath(__file__))
30
pitivi_dir = os.path.join(tests_dir, os.path.pardir)
31
return os.path.abspath(pitivi_dir)
35
from pitivi.configure import in_devel
38
build_dir = get_pitivi_dir()
40
# Probably running make distcheck. The path to the test files
41
# is different than the build path, so we must use the current
42
# dir which is build_path/tests.
43
build_dir = os.path.join(os.path.abspath(os.path.curdir), os.path.pardir)
44
return os.path.abspath(build_dir)
48
# Make available to configure.py the top level dir.
49
pitivi_dir = get_pitivi_dir()
50
os.environ.setdefault('PITIVI_TOP_LEVEL_DIR', pitivi_dir)
52
# Make available the compiled C code.
53
build_dir = get_build_dir()
54
libs_dir = os.path.join(build_dir, "pitivi/coptimizations/.libs")
55
sys.path.append(libs_dir)
57
# Make sure the modules are initialized correctly.
58
from pitivi.check import initialize_modules
63
except ImportError, e:
64
raise Exception("Python mock library missing! www.voidspace.org.uk/python/mock", e)
67
if __name__ == "__main__":
73
if 'VERBOSE' in os.environ:
76
from pitivi.utils import loggable as log
77
log.init('PITIVI_DEBUG')
79
suite = _tests_suite()
81
raise Exception("No tests found")
84
testRunner = unittest.TextTestRunner(descriptions=descriptions,
86
result = testRunner.run(suite)
87
if result.failures or result.errors: