File: runtests.py

package info (click to toggle)
yapsy 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 652 kB
  • sloc: python: 2,696; makefile: 82
file content (64 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/python
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t; python-indent: 4 -*-


"""
Main file to launch the tests.
"""

import sys
import getopt
import unittest
import logging


from test.test_All import MainTestSuite

def usage():
	"""
	Show/explain the options.
	"""
	return """python main.py [OPTIONS]

Options:

	-h or --help Print this help text

	-d Switch the logger to DEBUG mode.

	-v Switch the test to verbose mode.
"""


def main(argv):
	"""
	Launch all the test.
	"""
	try:
		opts, args = getopt.getopt(argv[1:], "vdh", ["help"])
	except getopt.GetoptError:
		print(usage())
		sys.exit(2)	
	loglevel = logging.ERROR
	test_verbosity = 1
	for o,a in opts:
		if o in ("-h","--help"):
			print(usage())
			sys.exit(0)
		elif o == "-d":
			loglevel = logging.DEBUG
		elif o == "-v":
			test_verbosity = 2
	logging.basicConfig(level= loglevel,
						format='%(asctime)s %(levelname)s %(message)s')
	
	# launch the testing process
	unittest.TextTestRunner(verbosity=test_verbosity).run(MainTestSuite)
	

	
if __name__=="__main__":
	main(sys.argv)