Skip to content

Stop shadowing the 'format' builtin #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2020
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
4 changes: 2 additions & 2 deletions pytest_html/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
FORMAT_VIDEO = "video"


def extra(content, format, name=None, mime_type=None, extension=None):
def extra(content, format_type, name=None, mime_type=None, extension=None):
return {
"name": name,
"format": format,
"format_type": format_type,
"content": content,
"mime_type": mime_type,
"extension": extension,
Expand Down
14 changes: 7 additions & 7 deletions pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ def create_asset(

def append_extra_html(self, extra, extra_index, test_index):
href = None
if extra.get("format") == extras.FORMAT_IMAGE:
if extra.get("format_type") == extras.FORMAT_IMAGE:
self._append_image(extra, extra_index, test_index)

elif extra.get("format") == extras.FORMAT_HTML:
elif extra.get("format_type") == extras.FORMAT_HTML:
self.additional_html.append(html.div(raw(extra.get("content"))))

elif extra.get("format") == extras.FORMAT_JSON:
elif extra.get("format_type") == extras.FORMAT_JSON:
content = json.dumps(extra.get("content"))
if self.self_contained:
href = data_uri(content, mime_type=extra.get("mime_type"))
Expand All @@ -250,7 +250,7 @@ def append_extra_html(self, extra, extra_index, test_index):
content, extra_index, test_index, extra.get("extension")
)

elif extra.get("format") == extras.FORMAT_TEXT:
elif extra.get("format_type") == extras.FORMAT_TEXT:
content = extra.get("content")
if isinstance(content, bytes):
content = content.decode("utf-8")
Expand All @@ -261,17 +261,17 @@ def append_extra_html(self, extra, extra_index, test_index):
content, extra_index, test_index, extra.get("extension")
)

elif extra.get("format") == extras.FORMAT_URL:
elif extra.get("format_type") == extras.FORMAT_URL:
href = extra.get("content")

elif extra.get("format") == extras.FORMAT_VIDEO:
elif extra.get("format_type") == extras.FORMAT_VIDEO:
self._append_video(extra, extra_index, test_index)

if href is not None:
self.links_html.append(
html.a(
extra.get("name"),
class_=extra.get("format"),
class_=extra.get("format_type"),
href=href,
target="_blank",
)
Expand Down