Skip to content

Commit 64bb5f2

Browse files
authored
Merge pull request #8091 from cmecklenborg/pytester_refactor_test_parseopt
Migrate test_parseopt.py from testdir to pytester
2 parents 0d0dfdd + 4abd711 commit 64bb5f2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

testing/test_parseopt.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import pytest
1010
from _pytest.config import argparsing as parseopt
1111
from _pytest.config.exceptions import UsageError
12+
from _pytest.monkeypatch import MonkeyPatch
13+
from _pytest.pytester import Pytester
1214

1315

1416
@pytest.fixture
@@ -287,7 +289,7 @@ def test_multiple_metavar_help(self, parser: parseopt.Parser) -> None:
287289
assert "--preferences=value1 value2 value3" in help
288290

289291

290-
def test_argcomplete(testdir, monkeypatch) -> None:
292+
def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
291293
try:
292294
bash_version = subprocess.run(
293295
["bash", "--version"],
@@ -302,7 +304,7 @@ def test_argcomplete(testdir, monkeypatch) -> None:
302304
# See #7518.
303305
pytest.skip("not a real bash")
304306

305-
script = str(testdir.tmpdir.join("test_argcomplete"))
307+
script = str(pytester.path.joinpath("test_argcomplete"))
306308

307309
with open(str(script), "w") as fp:
308310
# redirect output from argcomplete to stdin and stderr is not trivial
@@ -323,7 +325,7 @@ def test_argcomplete(testdir, monkeypatch) -> None:
323325
arg = "--fu"
324326
monkeypatch.setenv("COMP_LINE", "pytest " + arg)
325327
monkeypatch.setenv("COMP_POINT", str(len("pytest " + arg)))
326-
result = testdir.run("bash", str(script), arg)
328+
result = pytester.run("bash", str(script), arg)
327329
if result.ret == 255:
328330
# argcomplete not found
329331
pytest.skip("argcomplete not available")
@@ -339,5 +341,5 @@ def test_argcomplete(testdir, monkeypatch) -> None:
339341
arg = "test_argc"
340342
monkeypatch.setenv("COMP_LINE", "pytest " + arg)
341343
monkeypatch.setenv("COMP_POINT", str(len("pytest " + arg)))
342-
result = testdir.run("bash", str(script), arg)
344+
result = pytester.run("bash", str(script), arg)
343345
result.stdout.fnmatch_lines(["test_argcomplete", "test_argcomplete.d/"])

0 commit comments

Comments
 (0)