Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: Remove the unserializable cleanup
  • Loading branch information
BeyondEvil committed Oct 31, 2023
commit 55c6e55e138c72260a609fada7d725b477fa5dc7
3 changes: 1 addition & 2 deletions src/pytest_html/basereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from pytest_html import __version__
from pytest_html import extras
from pytest_html.util import cleanup_unserializable


class BaseReport:
Expand Down Expand Up @@ -49,7 +48,7 @@ def _asset_filename(self, test_id, extra_index, test_index, file_extension):

def _generate_report(self, self_contained=False):
generated = datetime.datetime.now()
test_data = cleanup_unserializable(self._report.data)
test_data = self._report.data
test_data = json.dumps(test_data)
rendered_report = self._template.render(
title=self._report.title,
Expand Down
15 changes: 0 additions & 15 deletions src/pytest_html/util.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import json
from functools import partial
from typing import Any
from typing import Dict

from jinja2 import Environment
from jinja2 import FileSystemLoader
Expand All @@ -23,18 +20,6 @@
_ansi_styles = []


def cleanup_unserializable(d: Dict[str, Any]) -> Dict[str, Any]:
"""Return new dict with entries that are not json serializable by their str()."""
result = {}
for k, v in d.items():
try:
json.dumps({k: v})
except TypeError:
v = str(v)
result[k] = v
return result


def _read_template(search_paths, template_name="index.jinja2"):
env = Environment(
loader=FileSystemLoader(search_paths),
Expand Down