Skip to content

Commit

Permalink
Upgrade pyupgrade to 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Nov 20, 2024
1 parent 30d44b9 commit 656506d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_html/basereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 11 additions & 12 deletions src/pytest_html/extras.py
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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,
Expand All @@ -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)


Expand All @@ -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)


Expand All @@ -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)
2 changes: 1 addition & 1 deletion testing/legacy_test_pytest_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 656506d

Please sign in to comment.