[flake8-bugbear] Fix all the useless expressions that are justified
This commit is contained in:
@@ -1241,9 +1241,9 @@ class TestWINLocalPath:
|
||||
|
||||
def test_owner_group_not_implemented(self, path1):
|
||||
with pytest.raises(NotImplementedError):
|
||||
path1.stat().owner
|
||||
_ = path1.stat().owner
|
||||
with pytest.raises(NotImplementedError):
|
||||
path1.stat().group
|
||||
_ = path1.stat().group
|
||||
|
||||
def test_chmod_simple_int(self, path1):
|
||||
mode = path1.stat().mode
|
||||
|
||||
@@ -387,7 +387,7 @@ def test_excinfo_no_python_sourcecode(tmp_path: Path) -> None:
|
||||
excinfo = pytest.raises(ValueError, template.render, h=h)
|
||||
for item in excinfo.traceback:
|
||||
print(item) # XXX: for some reason jinja.Template.render is printed in full
|
||||
item.source # shouldn't fail
|
||||
_ = item.source # shouldn't fail
|
||||
if isinstance(item.path, Path) and item.path.name == "test.txt":
|
||||
assert str(item.source) == "{{ h()}}:"
|
||||
|
||||
@@ -418,7 +418,7 @@ def test_codepath_Queue_example() -> None:
|
||||
|
||||
def test_match_succeeds():
|
||||
with pytest.raises(ZeroDivisionError) as excinfo:
|
||||
0 // 0
|
||||
_ = 0 // 0
|
||||
excinfo.match(r".*zero.*")
|
||||
|
||||
|
||||
@@ -584,7 +584,7 @@ class TestFormattedExcinfo:
|
||||
try:
|
||||
|
||||
def f():
|
||||
1 / 0
|
||||
_ = 1 / 0
|
||||
|
||||
f()
|
||||
|
||||
@@ -601,7 +601,7 @@ class TestFormattedExcinfo:
|
||||
print(line)
|
||||
assert lines == [
|
||||
" def f():",
|
||||
"> 1 / 0",
|
||||
"> _ = 1 / 0",
|
||||
"E ZeroDivisionError: division by zero",
|
||||
]
|
||||
|
||||
@@ -638,7 +638,7 @@ raise ValueError()
|
||||
pr = FormattedExcinfo()
|
||||
|
||||
try:
|
||||
1 / 0
|
||||
_ = 1 / 0
|
||||
except ZeroDivisionError:
|
||||
excinfo = ExceptionInfo.from_current()
|
||||
|
||||
@@ -1582,7 +1582,7 @@ def test_no_recursion_index_on_recursion_error():
|
||||
return getattr(self, "_" + attr)
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
RecursionDepthError().trigger
|
||||
_ = RecursionDepthError().trigger
|
||||
assert "maximum recursion" in str(excinfo.getrepr())
|
||||
|
||||
|
||||
|
||||
@@ -170,9 +170,9 @@ class ErrorsHelper:
|
||||
def test_helper_failures() -> None:
|
||||
helper = ErrorsHelper()
|
||||
with pytest.raises(Exception):
|
||||
helper.raise_exception
|
||||
_ = helper.raise_exception
|
||||
with pytest.raises(OutcomeException):
|
||||
helper.raise_fail_outcome
|
||||
_ = helper.raise_fail_outcome
|
||||
|
||||
|
||||
def test_safe_getattr() -> None:
|
||||
|
||||
@@ -108,7 +108,7 @@ class TestFixtureRequestSessionScoped:
|
||||
AttributeError,
|
||||
match="path not available in session-scoped context",
|
||||
):
|
||||
session_request.fspath
|
||||
_ = session_request.fspath
|
||||
|
||||
|
||||
@pytest.mark.parametrize("config_type", ["ini", "pyproject"])
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestMark:
|
||||
def test_pytest_mark_name_starts_with_underscore(self) -> None:
|
||||
mark = MarkGenerator(_ispytest=True)
|
||||
with pytest.raises(AttributeError):
|
||||
mark._some_name
|
||||
_ = mark._some_name
|
||||
|
||||
|
||||
def test_marked_class_run_twice(pytester: Pytester) -> None:
|
||||
|
||||
Reference in New Issue
Block a user