diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 78539b9a..582e6b1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: rev: 1.19.1 hooks: - id: blacken-docs - additional_dependencies: [black==22.3.0] + additional_dependencies: [black==24.10.0] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 @@ -50,7 +50,7 @@ repos: rev: v3.19.0 hooks: - id: pyupgrade - args: [--py3-plus] + args: [--py39-plus] - repo: https://github.com/pre-commit/mirrors-eslint rev: v9.15.0 diff --git a/src/pytest_html/basereport.py b/src/pytest_html/basereport.py index f1bc9e6c..cfcc74b2 100644 --- a/src/pytest_html/basereport.py +++ b/src/pytest_html/basereport.py @@ -306,7 +306,7 @@ def _process_report(self, report, duration, processed_extras): def _format_duration(duration): if duration < 1: - return "{} ms".format(round(duration * 1000)) + return f"{round(duration * 1000)} ms" hours = math.floor(duration / 3600) remaining_seconds = duration % 3600 diff --git a/src/pytest_html/extras.py b/src/pytest_html/extras.py index abf7e4c8..f736a017 100644 --- a/src/pytest_html/extras.py +++ b/src/pytest_html/extras.py @@ -1,7 +1,6 @@ # 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/. -from typing import Dict from typing import Optional FORMAT_HTML = "html" @@ -18,7 +17,7 @@ def extra( name: Optional[str] = None, mime_type: Optional[str] = None, extension: Optional[str] = None, -) -> Dict[str, Optional[str]]: +) -> dict[str, Optional[str]]: return { "name": name, "format_type": format_type, @@ -28,7 +27,7 @@ def extra( } -def html(content: str) -> Dict[str, Optional[str]]: +def html(content: str) -> dict[str, Optional[str]]: return extra(content, FORMAT_HTML) @@ -37,31 +36,31 @@ def image( name: str = "Image", mime_type: str = "image/png", extension: str = "png", -) -> Dict[str, Optional[str]]: +) -> dict[str, Optional[str]]: return extra(content, FORMAT_IMAGE, name, mime_type, extension) -def png(content: str, name: str = "Image") -> Dict[str, Optional[str]]: +def png(content: str, name: str = "Image") -> dict[str, Optional[str]]: return image(content, name, mime_type="image/png", extension="png") -def jpg(content: str, name: str = "Image") -> Dict[str, Optional[str]]: +def jpg(content: str, name: str = "Image") -> dict[str, Optional[str]]: return image(content, name, mime_type="image/jpeg", extension="jpg") -def svg(content: str, name: str = "Image") -> Dict[str, Optional[str]]: +def svg(content: str, name: str = "Image") -> dict[str, Optional[str]]: return image(content, name, mime_type="image/svg+xml", extension="svg") -def json(content: str, name: str = "JSON") -> Dict[str, Optional[str]]: +def json(content: str, name: str = "JSON") -> dict[str, Optional[str]]: return extra(content, FORMAT_JSON, name, "application/json", "json") -def text(content: str, name: str = "Text") -> Dict[str, Optional[str]]: +def text(content: str, name: str = "Text") -> dict[str, Optional[str]]: return extra(content, FORMAT_TEXT, name, "text/plain", "txt") -def url(content: str, name: str = "URL") -> Dict[str, Optional[str]]: +def url(content: str, name: str = "URL") -> dict[str, Optional[str]]: return extra(content, FORMAT_URL, name) @@ -70,9 +69,9 @@ def video( name: str = "Video", mime_type: str = "video/mp4", extension: str = "mp4", -) -> Dict[str, Optional[str]]: +) -> dict[str, Optional[str]]: return extra(content, FORMAT_VIDEO, name, mime_type, extension) -def mp4(content: str, name: str = "Video") -> Dict[str, Optional[str]]: +def mp4(content: str, name: str = "Video") -> dict[str, Optional[str]]: return video(content, name) diff --git a/testing/legacy_test_pytest_html.py b/testing/legacy_test_pytest_html.py index 1ae82e20..08ad208d 100644 --- a/testing/legacy_test_pytest_html.py +++ b/testing/legacy_test_pytest_html.py @@ -28,7 +28,7 @@ def read_html(path): def assert_results_by_outcome(html, test_outcome, test_outcome_number, label=None): # Asserts if the test number of this outcome in the summary is correct - regex_summary = r"(\d)+ {}".format(label or test_outcome) + regex_summary = rf"(\d)+ {label or test_outcome}" assert int(re.search(regex_summary, html).group(1)) == test_outcome_number # Asserts if the generated checkbox of this outcome is correct