Skip to content

Commit 8d0f642

Browse files
committed
Fix pre-commit issues
1 parent a69ec13 commit 8d0f642

File tree

8 files changed

+95
-84
lines changed

8 files changed

+95
-84
lines changed

.eslintrc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"no-var": "error",
4848
"object-curly-spacing": [
4949
"error",
50-
"always",
51-
{
52-
"arraysInObjects": true
50+
"always",
51+
{
52+
"arraysInObjects": true
5353
}
5454
],
5555
"prefer-const": "error",

.github/workflows/actions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
github.event_name == 'create' &&
9292
github.event.ref_type == 'tag'
9393
)
94-
uses: pypa/gh-action-pypi-publish@v1
94+
uses: pypa/gh-action-pypi-publish@release/v1
9595
with:
9696
password: ${{ secrets.testpypi_password }}
9797
repository_url: https://test.pypi.org/legacy/
@@ -100,6 +100,6 @@ jobs:
100100
if: >- # "create" workflows run separately from "push" & "pull_request"
101101
github.event_name == 'create' &&
102102
github.event.ref_type == 'tag'
103-
uses: pypa/gh-action-pypi-publish@v1
103+
uses: pypa/gh-action-pypi-publish@release/v1
104104
with:
105105
password: ${{ secrets.pypi_password }}

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ jobs:
109109
# TODO: https://github.com/pytest-dev/pytest-html/issues/481
110110
- name: Upload coverage to codecov
111111
if: >-
112-
${{
113-
! github.event.schedule &&
112+
${{
113+
! github.event.schedule &&
114114
! matrix.skip-coverage &&
115115
github.repository_owner == 'pytest-dev'
116116
}}

.pre-commit-config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ repos:
33
rev: 22.3.0
44
hooks:
55
- id: black
6-
args: [--safe, --quiet]
6+
args: [--safe, --quiet, --line-length=88]
7+
78
- repo: https://github.com/asottile/blacken-docs
89
rev: v1.12.1
910
hooks:
1011
- id: blacken-docs
1112
additional_dependencies: [black==22.3.0]
13+
1214
- repo: https://github.com/pre-commit/pre-commit-hooks
1315
rev: v4.1.0
1416
hooks:
@@ -19,6 +21,7 @@ repos:
1921
- id: check-yaml
2022
- id: debug-statements
2123
language_version: python3
24+
2225
- repo: https://github.com/PyCQA/flake8
2326
rev: 4.0.1
2427
hooks:
@@ -27,23 +30,27 @@ repos:
2730
additional_dependencies:
2831
- flake8-builtins==1.5.3
2932
- flake8-typing-imports==1.12.0
33+
3034
- repo: https://github.com/asottile/reorder_python_imports
3135
rev: v3.0.1
3236
hooks:
3337
- id: reorder-python-imports
3438
args: ["--application-directories=.:src:testing", --py3-plus]
39+
3540
- repo: https://github.com/asottile/pyupgrade
3641
rev: v2.32.0
3742
hooks:
3843
- id: pyupgrade
3944
args: [--py3-plus]
45+
4046
# - repo: https://github.com/pre-commit/mirrors-eslint
4147
# rev: v7.13.0
4248
# hooks:
4349
# - id: eslint
4450
# additional_dependencies:
4551
# - eslint@7.13.0
4652
# args: [src]
53+
4754
- repo: local
4855
hooks:
4956
- id: rst
@@ -52,6 +59,7 @@ repos:
5259
files: ^(README.rst)$
5360
language: python
5461
additional_dependencies: [pygments, restructuredtext_lint]
62+
5563
- repo: https://github.com/elidupuis/mirrors-sass-lint
5664
rev: "5cc45653263b423398e4af2561fae362903dd45d"
5765
hooks:

src/pytest_html/nextgen.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import datetime
44
import json
55
import os
6-
import pytest
76
import re
87
import warnings
9-
108
from collections import defaultdict
119
from functools import partial
1210
from pathlib import Path
11+
12+
import pytest
1313
from jinja2 import Environment
1414
from jinja2 import FileSystemLoader
1515
from jinja2 import select_autoescape
@@ -22,9 +22,7 @@
2222
try:
2323
from ansi2html import Ansi2HTMLConverter, style
2424

25-
converter = Ansi2HTMLConverter(
26-
inline=False, escaped=False
27-
)
25+
converter = Ansi2HTMLConverter(inline=False, escaped=False)
2826
_handle_ansi = partial(converter.convert, full=False)
2927
_ansi_styles = style.get_styles()
3028
except ImportError:
@@ -34,8 +32,8 @@
3432
_ansi_styles = []
3533

3634

37-
class BaseReport(object):
38-
class Cells(object):
35+
class BaseReport:
36+
class Cells:
3937
def __init__(self):
4038
self._html = {}
4139

@@ -46,7 +44,7 @@ def html(self):
4644
def insert(self, index, html):
4745
self._html[index] = html
4846

49-
class Report(object):
47+
class Report:
5048
def __init__(self, title, duration_format):
5149
self._data = {
5250
"title": title,
@@ -80,9 +78,13 @@ def __init__(self, report_path, config, default_css="style.css"):
8078
self._resources_path = Path(__file__).parent.joinpath("resources")
8179
self._config = config
8280
self._template = _read_template([self._resources_path])
83-
self._css = _process_css(Path(self._resources_path, default_css), self._config.getoption("css"))
81+
self._css = _process_css(
82+
Path(self._resources_path, default_css), self._config.getoption("css")
83+
)
8484
self._duration_format = config.getini("duration_format")
85-
self._max_asset_filename_length = int(config.getini("max_asset_filename_length"))
85+
self._max_asset_filename_length = int(
86+
config.getini("max_asset_filename_length")
87+
)
8688
self._report = self.Report(self._report_path.name, self._duration_format)
8789

8890
@property
@@ -96,7 +98,7 @@ def _asset_filename(self, test_id, extra_index, test_index, file_extension):
9698
str(extra_index),
9799
str(test_index),
98100
file_extension,
99-
)[-self._max_asset_filename_length:]
101+
)[-self._max_asset_filename_length :]
100102

101103
def _generate_report(self, self_contained=False):
102104
generated = datetime.datetime.now()
@@ -147,19 +149,28 @@ def _process_extras(self, report, test_id):
147149
test_id.encode("utf-8").decode("unicode_escape"),
148150
extra_index,
149151
test_index,
150-
extra['extension']
152+
extra["extension"],
151153
)
152154
if extra["format_type"] == extras.FORMAT_JSON:
153155
content = json.dumps(content)
154-
extra["content"] = self._data_content(content, asset_name=asset_name, mime_type=extra["mime_type"])
156+
extra["content"] = self._data_content(
157+
content, asset_name=asset_name, mime_type=extra["mime_type"]
158+
)
155159

156160
if extra["format_type"] == extras.FORMAT_TEXT:
157161
if isinstance(content, bytes):
158162
content = content.decode("utf-8")
159-
extra["content"] = self._data_content(content, asset_name=asset_name, mime_type=extra["mime_type"])
160-
161-
if extra["format_type"] == extras.FORMAT_IMAGE or extra["format_type"] == extras.FORMAT_VIDEO:
162-
extra["content"] = self._media_content(content, asset_name=asset_name, mime_type=extra["mime_type"])
163+
extra["content"] = self._data_content(
164+
content, asset_name=asset_name, mime_type=extra["mime_type"]
165+
)
166+
167+
if (
168+
extra["format_type"] == extras.FORMAT_IMAGE
169+
or extra["format_type"] == extras.FORMAT_VIDEO
170+
):
171+
extra["content"] = self._media_content(
172+
content, asset_name=asset_name, mime_type=extra["mime_type"]
173+
)
163174

164175
return report_extras
165176

@@ -218,7 +229,9 @@ def pytest_sessionfinish(self, session):
218229

219230
@pytest.hookimpl(trylast=True)
220231
def pytest_terminal_summary(self, terminalreporter):
221-
terminalreporter.write_sep("-", f"Generated html report: file://{self._report_path.resolve()}")
232+
terminalreporter.write_sep(
233+
"-", f"Generated html report: file://{self._report_path.resolve()}"
234+
)
222235

223236
@pytest.hookimpl(trylast=True)
224237
def pytest_collection_finish(self, session):
@@ -307,7 +320,7 @@ def _media_content(self, content, mime_type, *args, **kwargs):
307320
base64.b64decode(content.encode("utf-8"), validate=True)
308321
return f"data:{mime_type};base64,{content}"
309322
except binascii.Error:
310-
# if not base64 content, issue warning and just return as it's a file or link
323+
# if not base64, issue warning and just return as it's a file or link
311324
warnings.warn(
312325
"Self-contained HTML report "
313326
"includes link to external "
@@ -361,7 +374,7 @@ def _read_template(search_paths, template_name="index.jinja2"):
361374
env = Environment(
362375
loader=FileSystemLoader(search_paths),
363376
autoescape=select_autoescape(
364-
enabled_extensions=('jinja2',),
377+
enabled_extensions=("jinja2",),
365378
),
366379
)
367380
return env.get_template(template_name)

src/pytest_html/plugin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
import pytest
54
import warnings
65
from pathlib import Path
76

8-
from . import extras # noqa: F401
7+
import pytest
8+
99
from .nextgen import NextGenReport
1010
from .nextgen import NextGenSelfContainedReport
1111

@@ -121,8 +121,9 @@ def test_foo(extra):
121121
extra.append(pytest_html.extras.url("https://www.example.com/"))
122122
"""
123123
warnings.warn(
124-
"The 'extra' fixture is deprecated and will be removed in a future release, use 'extras' instead.",
125-
DeprecationWarning
124+
"The 'extra' fixture is deprecated and will be removed in a future release"
125+
", use 'extras' instead.",
126+
DeprecationWarning,
126127
)
127128
pytestconfig.extras = []
128129
yield pytestconfig.extras

src/pytest_html/resources/index.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
</div>
5050
<div class="media-container__nav--right">></div>
5151
</div>
52-
<div class="media__name"></div>
53-
<div class="media__counter"></div>
52+
<div class="media__name"></div>
53+
<div class="media__counter"></div>
5454
</div>
5555
<div class="log"></div>
5656
</td>

0 commit comments

Comments
 (0)