File: testall.py

package info (click to toggle)
python-bottle 0.12.7-1%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,568 kB
  • ctags: 2,288
  • sloc: python: 5,711; makefile: 68; sh: 62
file content (45 lines) | stat: -rwxr-xr-x 1,119 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

try:
    import coverage
    coverage.process_startup()
except ImportError:
    pass

import unittest
import sys, os, glob

test_root = os.path.dirname(os.path.abspath(__file__))
test_files = glob.glob(os.path.join(test_root, 'test_*.py'))

os.chdir(test_root)
sys.path.insert(0, os.path.dirname(test_root))
sys.path.insert(0, test_root)
test_names = [os.path.basename(name)[:-3] for name in test_files]

if 'help' in sys.argv or '-h' in sys.argv:
    sys.stdout.write('''Command line arguments:
    fast: Skip server adapter tests.
    verbose: Print tests even if they pass.
    ''')
    sys.exit(0)

if 'fast' in sys.argv:
    sys.stderr.write("Warning: The 'fast' keyword skipps server tests.\n")
    test_names.remove('test_server')

suite = unittest.defaultTestLoader.loadTestsFromNames(test_names)

def run():
    import bottle

    bottle.debug(True)
    vlevel = 2 if 'verbose' in sys.argv else 0
    result = unittest.TextTestRunner(verbosity=vlevel).run(suite)

    sys.exit((result.errors or result.failures) and 1 or 0)

if __name__ == '__main__':
    run()