Skip to content

Commit d21f59f

Browse files
committed
Fix typing errors after updating mypy
1 parent 82ecdea commit d21f59f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

testing/test_looponfail.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import cast
2+
13
import py
24
import pytest
35
import shutil
@@ -123,7 +125,7 @@ def test_failures_somewhere(self, pytester: pytest.Pytester) -> None:
123125
failures = control.runsession()
124126
assert failures
125127
control.setup()
126-
item_path = item.path if PYTEST_GTE_7 else Path(item.fspath) # type: ignore[attr-defined]
128+
item_path = item.path if PYTEST_GTE_7 else Path(cast(py.path.local, item.fspath)) # type: ignore[attr-defined]
127129
item_path.write_text("def test_func():\n assert 1\n")
128130
removepyc(item_path)
129131
topdir, failures = control.runsession()[:2]
@@ -141,7 +143,11 @@ def test_func():
141143
control = RemoteControl(modcol.config)
142144
control.loop_once()
143145
assert control.failures
144-
modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath) # type: ignore[attr-defined]
146+
if PYTEST_GTE_7:
147+
modcol_path = modcol.path # type:ignore[attr-defined]
148+
else:
149+
modcol_path = Path(cast(py.path.local, modcol.fspath))
150+
145151
modcol_path.write_text(
146152
textwrap.dedent(
147153
"""
@@ -173,7 +179,7 @@ def test_func():
173179
if PYTEST_GTE_7:
174180
parent = modcol.path.parent.parent # type: ignore[attr-defined]
175181
else:
176-
parent = Path(modcol.fspath.dirpath().dirpath())
182+
parent = Path(cast(py.path.local, modcol.fspath).dirpath().dirpath())
177183
monkeypatch.chdir(parent)
178184
modcol.config.args = [
179185
str(Path(x).relative_to(parent)) for x in modcol.config.args

0 commit comments

Comments
 (0)