Skip to content

Commit fcc6bcd

Browse files
authored
add optionally parent uuid for attach (via #575)
1 parent 6ccf068 commit fcc6bcd

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

allure-python-commons/src/lifecycle.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def stop_after_fixture(self, uuid=None):
123123
if fixture and not fixture.stop:
124124
fixture.stop = now()
125125

126-
def _attach(self, uuid, name=None, attachment_type=None, extension=None):
126+
def _attach(self, uuid, name=None, attachment_type=None, extension=None, parent_uuid=None):
127127
mime_type = attachment_type
128128
extension = extension if extension else 'attach'
129129

@@ -133,15 +133,17 @@ def _attach(self, uuid, name=None, attachment_type=None, extension=None):
133133

134134
file_name = ATTACHMENT_PATTERN.format(prefix=uuid, ext=extension)
135135
attachment = Attachment(source=file_name, name=name, type=mime_type)
136-
uuid = self._last_item_uuid(item_type=ExecutableItem)
137-
self._items[uuid].attachments.append(attachment)
136+
last_uuid = parent_uuid if parent_uuid else self._last_item_uuid(ExecutableItem)
137+
self._items[last_uuid].attachments.append(attachment)
138138

139139
return file_name
140140

141-
def attach_file(self, uuid, source, name=None, attachment_type=None, extension=None):
142-
file_name = self._attach(uuid, name=name, attachment_type=attachment_type, extension=extension)
141+
def attach_file(self, uuid, source, name=None, attachment_type=None, extension=None, parent_uuid=None):
142+
file_name = self._attach(uuid, name=name, attachment_type=attachment_type,
143+
extension=extension, parent_uuid=parent_uuid)
143144
plugin_manager.hook.report_attached_file(source=source, file_name=file_name)
144145

145-
def attach_data(self, uuid, body, name=None, attachment_type=None, extension=None):
146-
file_name = self._attach(uuid, name=name, attachment_type=attachment_type, extension=extension)
146+
def attach_data(self, uuid, body, name=None, attachment_type=None, extension=None, parent_uuid=None):
147+
file_name = self._attach(uuid, name=name, attachment_type=attachment_type,
148+
extension=extension, parent_uuid=parent_uuid)
147149
plugin_manager.hook.report_attached_data(body=body, file_name=file_name)

allure-python-commons/src/reporter.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def stop_step(self, uuid, **kwargs):
9393
self._update_item(uuid, **kwargs)
9494
self._items.pop(uuid)
9595

96-
def _attach(self, uuid, name=None, attachment_type=None, extension=None):
96+
def _attach(self, uuid, name=None, attachment_type=None, extension=None, parent_uuid=None):
9797
mime_type = attachment_type
9898
extension = extension if extension else 'attach'
9999

@@ -103,15 +103,17 @@ def _attach(self, uuid, name=None, attachment_type=None, extension=None):
103103

104104
file_name = ATTACHMENT_PATTERN.format(prefix=uuid, ext=extension)
105105
attachment = Attachment(source=file_name, name=name, type=mime_type)
106-
last_uuid = self._last_executable()
106+
last_uuid = parent_uuid if parent_uuid else self._last_executable()
107107
self._items[last_uuid].attachments.append(attachment)
108108

109109
return file_name
110110

111-
def attach_file(self, uuid, source, name=None, attachment_type=None, extension=None):
112-
file_name = self._attach(uuid, name=name, attachment_type=attachment_type, extension=extension)
111+
def attach_file(self, uuid, source, name=None, attachment_type=None, extension=None, parent_uuid=None):
112+
file_name = self._attach(uuid, name=name, attachment_type=attachment_type,
113+
extension=extension, parent_uuid=parent_uuid)
113114
plugin_manager.hook.report_attached_file(source=source, file_name=file_name)
114115

115-
def attach_data(self, uuid, body, name=None, attachment_type=None, extension=None):
116-
file_name = self._attach(uuid, name=name, attachment_type=attachment_type, extension=extension)
116+
def attach_data(self, uuid, body, name=None, attachment_type=None, extension=None, parent_uuid=None):
117+
file_name = self._attach(uuid, name=name, attachment_type=attachment_type,
118+
extension=extension, parent_uuid=parent_uuid)
117119
plugin_manager.hook.report_attached_data(body=body, file_name=file_name)

0 commit comments

Comments
 (0)