Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
88 lines (71 loc) · 2.7 KB

File metadata and controls

88 lines (71 loc) · 2.7 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import errno
import io
import os
import sys
import json
import uuid
import shutil
from six import text_type
from attr import asdict
from allure_commons import hookimpl
INDENT = 4
class AllureFileLogger(object):
def __init__(self, report_dir, clean=False):
self._report_dir = report_dir
try:
os.makedirs(report_dir)
except OSError as e:
if e.errno != errno.EEXIST:
raise
elif clean:
for f in os.listdir(report_dir):
f = os.path.join(report_dir, f)
if os.path.isfile(f):
os.unlink(f)
def _report_item(self, item):
indent = INDENT if os.environ.get("ALLURE_INDENT_OUTPUT") else None
filename = item.file_pattern.format(prefix=uuid.uuid4())
data = asdict(item, filter=lambda attr, value: not (type(value) != bool and not bool(value)))
with io.open(os.path.join(self._report_dir, filename), 'w', encoding='utf8') as json_file:
if sys.version_info.major < 3:
json_file.write(
unicode(json.dumps(data, indent=indent, ensure_ascii=False, encoding='utf8'))) # noqa: F821
else:
json.dump(data, json_file, indent=indent, ensure_ascii=False)
@hookimpl
def report_result(self, result):
self._report_item(result)
@hookimpl
def report_container(self, container):
self._report_item(container)
@hookimpl
def report_attached_file(self, source, file_name):
destination = os.path.join(self._report_dir, file_name)
shutil.copy2(source, destination)
@hookimpl
def report_attached_data(self, body, file_name):
destination = os.path.join(self._report_dir, file_name)
with open(destination, 'wb') as attached_file:
if isinstance(body, text_type):
attached_file.write(body.encode('utf-8'))
else:
attached_file.write(body)
class AllureMemoryLogger(object):
def __init__(self):
self.test_cases = []
self.test_containers = []
self.attachments = {}
@hookimpl
def report_result(self, result):
data = asdict(result, filter=lambda attr, value: not (type(value) != bool and not bool(value)))
self.test_cases.append(data)
@hookimpl
def report_container(self, container):
data = asdict(container, filter=lambda attr, value: not (type(value) != bool and not bool(value)))
self.test_containers.append(data)
@hookimpl
def report_attached_file(self, source, file_name):
pass
@hookimpl
def report_attached_data(self, body, file_name):
self.attachments[file_name] = body
Morty Proxy This is a proxified and sanitized view of the page, visit original site.