-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_suite.py
67 lines (54 loc) · 1.83 KB
/
test_suite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# coding=utf-8
"""
Test Suite for GeoHealth.
Contact : etienne at kartoza dot com
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
from __future__ import print_function
import sys
import unittest
import qgis
import inspect
from os.path import abspath, dirname, exists
from os import listdir
from osgeo import gdal
__author__ = 'etiennetrimaille'
__revision__ = '$Format:%H$'
__date__ = '14/06/2016'
def _run_tests(test_suite, package_name):
"""Core function to test a test suite."""
count = test_suite.countTestCases()
# fix_print_with_import
# fix_print_with_import
print('########')
# fix_print_with_import
# fix_print_with_import
print('%s tests has been discovered in %s' % (count, package_name))
# fix_print_with_import
# fix_print_with_import
print('Python GDAL : %s' % gdal.VersionInfo('VERSION_NUM'))
# fix_print_with_import
# fix_print_with_import
print('########')
currentdir = dirname(abspath(inspect.getfile(inspect.currentframe())))
parentdir = dirname(currentdir)
sys.path.insert(0, parentdir)
sys.path.insert(0, '/root/.qgis2/python/plugins/GeoHealth')
unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(test_suite)
def test_package(package='src'):
"""Test package.
This function is called by travis without arguments.
:param package: The package to test.
:type package: str
"""
test_loader = unittest.defaultTestLoader
try:
test_suite = test_loader.discover(package)
except ImportError:
test_suite = unittest.TestSuite()
_run_tests(test_suite, package)
if __name__ == '__main__':
test_package()