File: run_all_unittests.py

package info (click to toggle)
python-pyelftools 0.32-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,964 kB
  • sloc: python: 15,903; ansic: 298; asm: 86; makefile: 24; cpp: 18; sh: 4
file content (33 lines) | stat: -rwxr-xr-x 1,006 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python
#-------------------------------------------------------------------------------
# test/run_all_unittests.py
#
# Run all unit tests (alternative to running 'python -m unittest discover ...')
#
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
from __future__ import print_function

import os, sys
import unittest

# Make it possible to run this file from the root dir of pyelftools without
# installing pyelftools; useful for CI testing, etc.
sys.path[0:0] = ['.']


def main():
    if not os.path.isdir('test'):
        print('!! Please execute from the root directory of pyelftools')
        return 1
    else:
        tests = unittest.TestLoader().discover('test', 'test*.py', 'test')
        result = unittest.TextTestRunner().run(tests)
        if result.wasSuccessful():
            return 0
        else:
            return 1

if __name__ == '__main__':
    sys.exit(main())