run 906 字节
Newer Older
1 2 3 4 5
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'Lucas Meneghel Rodrigues <lmr@redhat.com>'

6 7
import os
import sys
8
import logging
9 10


11 12 13 14
if sys.version_info[:2] == (2, 6):
    import unittest2 as unittest
else:
    import unittest
15 16 17 18

logger = logging.getLogger(__name__)


19 20 21 22 23 24 25 26 27
def test_suite():
    suite = unittest.TestSuite()
    loader = unittest.TestLoader()
    selftests_dir = os.path.dirname(os.path.abspath(__file__))
    basedir = os.path.dirname(selftests_dir)
    for section in ('unit', 'functional', 'doc'):
        suite.addTests(loader.discover(start_dir=os.path.join(selftests_dir, section),
                                       top_level_dir=basedir))
    return suite
28

29
if __name__ == '__main__':
30
    runner = unittest.TextTestRunner(failfast=not os.environ.get("SELF_CHECK_CONTINUOUS"))
31 32 33
    result = runner.run(test_suite())
    if result.failures or result.errors:
        sys.exit(1)