File: run_tests.py

package info (click to toggle)
python-scandir 1.10.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 224 kB
  • sloc: ansic: 1,596; python: 1,129; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 562 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Run all unit tests."""

import glob
import os
import sys
import unittest


def main():
    test_dir = os.path.dirname(os.path.abspath(__file__))
    test_files = glob.glob(os.path.join(test_dir, 'test_*.py'))
    test_names = [os.path.basename(f)[:-3] for f in test_files]

    sys.path.insert(0, os.path.join(test_dir, '..'))

    suite = unittest.defaultTestLoader.loadTestsFromNames(test_names)
    result = unittest.TextTestRunner(verbosity=2).run(suite)
    sys.exit(1 if (result.errors or result.failures) else 0)

if __name__ == '__main__':
    main()