1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import logging
20 import os.path
21 import random
22 import sys
23
24 from yakumo import Client, utils
25
26
27 __all__ = ('LOG', 'get_random_str', 'test', 'show_test_summary')
28
29 SOURCE = "abcdefghijklmnopqrstuvwxyz" \
30 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
31 "0123456789"
32
33 TEST_LOGS = []
34
35
36 LOG = logging.getLogger(os.path.basename(sys.argv[0]))
37 LOG.setLevel(logging.DEBUG)
38 ch = logging.StreamHandler()
39 ch.setLevel(logging.DEBUG)
40 formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
41 ch.setFormatter(formatter)
42 LOG.addHandler(ch)
43
44
46 return prefix + "-" + "".join(random.sample(SOURCE, 10))
47
48
49 -def test(label, condition):
55
56
58 _ok = 0
59 _ng = 0
60 for label, condition in TEST_LOGS:
61 if condition:
62 _ok += 1
63 else:
64 _ng += 1
65 LOG.info("Test results: OK=%s, NG=%s" % (_ok, _ng))
66 for label, condition in TEST_LOGS:
67 if not condition:
68 LOG.debug("NG: %s" % label)
69