forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.py
More file actions
28 lines (25 loc) · 791 Bytes
/
report.py
File metadata and controls
28 lines (25 loc) · 791 Bytes
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
from __future__ import print_function
import json
def report_discovered(tests, debug=False,
_send=print):
"""Serialize the discovered tests and write to stdout."""
data = [{
'id': test.id,
'name': test.name,
'testroot': test.path.root,
'relfile': test.path.relfile,
'lineno': test.lineno,
'testfunc': test.path.func,
'subtest': test.path.sub or None,
'markers': test.markers or None,
} for test in tests]
kwargs = {}
if debug:
# human-formatted
kwargs = dict(
sort_keys=True,
indent=4,
separators=(',', ': '),
)
serialized = json.dumps(data, **kwargs)
_send(serialized)