-
Notifications
You must be signed in to change notification settings - Fork 2
/
pytestdoc.py
executable file
·53 lines (46 loc) · 1.21 KB
/
pytestdoc.py
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
import json
def tattr_init(f):
if not hasattr(f, 'tattr'):
f.tattr = {}
def tattr_category(category):
def wrap(f):
tattr_init(f)
f.tattr['category'] = category
return f
return wrap
def tattr_doc(doc):
def wrap(f):
tattr_init(f)
f.tattr['docstr'] = doc
return f
return wrap
def tattr_annotate_bug(f, bugids, tracker, bugtype):
tattr_init(f)
bugs = []
assert(bugtype in ['feature', 'bug'])
assert(tracker in ['redmine', 'gitlab'])
for bugid in bugids:
#print "Appending %s -> %s" % (bugid, bugtype)
bugs.append({
'id': bugid,
'tracker': tracker,
'bugtype': bugtype,
})
if not 'bugs' in f.tattr:
f.tattr['bugs'] = []
f.tattr['bugs'].extend(bugs)
#print json.dumps(f.tattr, indent=4)
def tattr_redmine_feature(*bugids):
def wrap(f):
tattr_annotate_bug(f, bugids, 'redmine', 'feature')
return f
return wrap
def tattr_redmine_bug(*bugids):
def wrap(f):
tattr_annotate_bug(f, bugids, 'redmine', 'bug')
return f
return wrap
def tattr_incomplete(f):
tattr_init(f)
f.tattr['incomplete'] = True
return f