Skip to content

Commit 29f415e

Browse files
committed
pre-commit fixes
1 parent 9327065 commit 29f415e

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ old-version/
1818
/site/
1919
/site.zip
2020
/build/
21-
.venv
21+
.venv

devtools/pytest_plugin.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def insert_pytest_raises() -> Generator[None, Any, int]:
9595
yield
9696
except Exception as e:
9797
python_code = format_code(
98-
f'# with insert_pytest_raises():\nwith pytest.raises({type(e).__name__}, match=re.escape({repr(str(e))})):\n'
98+
f'# with insert_pytest_raises():\n'
99+
f'with pytest.raises({type(e).__name__}, match=re.escape({repr(str(e))})):\n'
99100
)
100101
python_code = textwrap.indent(python_code, statement.col_offset * ' ')
101102
to_replace.append(
@@ -215,19 +216,21 @@ def insert_assert_session(pytestconfig: pytest.Config) -> Generator[None, None,
215216
files += 1
216217
prefix = 'Printed' if print_instead else 'Replaced'
217218

218-
insert_assert_count = len([item for item in to_replace if item.instruction_type == "insert_assert"])
219-
insert_pytest_raises_count = len([item for item in to_replace if item.instruction_type == "insert_pytest_raises"])
219+
insert_assert_count = len([item for item in to_replace if item.instruction_type == 'insert_assert'])
220+
insert_pytest_raises_count = len([item for item in to_replace if item.instruction_type == 'insert_pytest_raises'])
220221
if insert_assert_count:
221222
summary.append(
222223
f'{prefix} {insert_assert_count} insert_assert() call{plural(to_replace)} in {files} file{plural(files)}'
223224
)
224225
if insert_pytest_raises_count:
225226
summary.append(
226-
f'{prefix} {insert_pytest_raises_count} insert_pytest_raises() call{plural(to_replace)} in {files} file{plural(files)}'
227+
f'{prefix} {insert_pytest_raises_count} insert_pytest_raises()'
228+
f' call{plural(to_replace)} in {files} file{plural(files)}'
227229
)
228230
if dup_count:
229231
summary.append(
230-
f'\n{dup_count} insert{plural(dup_count)} skipped because an assert statement on that line had already be inserted!'
232+
f'\n{dup_count} insert{plural(dup_count)}'
233+
' skipped because an assert statement on that line had already be inserted!'
231234
)
232235

233236
test_replacement_summary.set(summary)

tests/test_insert_pytest_raises.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import pytest
55

6-
from devtools.pytest_plugin import load_black
7-
86
pytestmark = pytest.mark.skipif(sys.version_info < (3, 8), reason='requires Python 3.8+')
97

108

@@ -160,6 +158,6 @@ def test_raise_keyerror(insert_pytest_raises):
160158
result.assert_outcomes(failed=1)
161159
captured = capsys.readouterr()
162160
assert (
163-
"RuntimeError: insert_pytest_raises() was called alongside other statements, this is not supported\n"
161+
'RuntimeError: insert_pytest_raises() was called alongside other statements, this is not supported\n'
164162
in captured.out
165163
)

0 commit comments

Comments
 (0)