Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions allure-python-commons/src/allure_commons/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ 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 _, v: v or v is False)
with io.open(self._report_dir / filename, "w", encoding="utf8") as json_file:

tmp_filepath = self._report_dir / f"{filename}.tmp"
final_filepath = self._report_dir / filename

with io.open(tmp_filepath, "w", encoding="utf8") as json_file:
json.dump(data, json_file, indent=indent, ensure_ascii=False)

os.replace(tmp_filepath, final_filepath)

@hookimpl
def report_result(self, result):
self._report_item(result)
Expand All @@ -35,17 +41,21 @@ def report_container(self, container):

@hookimpl
def report_attached_file(self, source, file_name):
destination = self._report_dir / file_name
shutil.copy2(source, destination)
tmp_destination = self._report_dir / f"{file_name}.tmp"
final_destination = self._report_dir / file_name
shutil.copy2(source, tmp_destination)
os.replace(tmp_destination, final_destination)

@hookimpl
def report_attached_data(self, body, file_name):
destination = self._report_dir / file_name
with open(destination, "wb") as attached_file:
tmp_destination = self._report_dir / f"{file_name}.tmp"
final_destination = self._report_dir / file_name
with open(tmp_destination, "wb") as attached_file:
if isinstance(body, str):
attached_file.write(body.encode("utf-8"))
else:
attached_file.write(body)
os.replace(tmp_destination, final_destination)

@hookimpl
def report_globals(self, globals_item):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_only_failed_steps_have_status_details(docstring, robot_runner: AllureRo
FOR ${value} IN @{TEST_VALUES}
Run Keyword And Ignore Error Should Be True ${value} > 10
END
Log To Console Test message
No Operation
"""

robot_runner.run_robotframework(
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_only_failed_steps_have_status_details(docstring, robot_runner: AllureRo
)
),
has_step(
"BuiltIn.Log To Console",
"BuiltIn.No Operation",
with_status("passed"),
has_status_details({})
)
Expand Down
Loading