9
9
import pytest
10
10
from _pytest .config import argparsing as parseopt
11
11
from _pytest .config .exceptions import UsageError
12
+ from _pytest .monkeypatch import MonkeyPatch
13
+ from _pytest .pytester import Pytester
12
14
13
15
14
16
@pytest .fixture
@@ -287,7 +289,7 @@ def test_multiple_metavar_help(self, parser: parseopt.Parser) -> None:
287
289
assert "--preferences=value1 value2 value3" in help
288
290
289
291
290
- def test_argcomplete (testdir , monkeypatch ) -> None :
292
+ def test_argcomplete (pytester : Pytester , monkeypatch : MonkeyPatch ) -> None :
291
293
try :
292
294
bash_version = subprocess .run (
293
295
["bash" , "--version" ],
@@ -302,7 +304,7 @@ def test_argcomplete(testdir, monkeypatch) -> None:
302
304
# See #7518.
303
305
pytest .skip ("not a real bash" )
304
306
305
- script = str (testdir . tmpdir . join ("test_argcomplete" ))
307
+ script = str (pytester . path . joinpath ("test_argcomplete" ))
306
308
307
309
with open (str (script ), "w" ) as fp :
308
310
# redirect output from argcomplete to stdin and stderr is not trivial
@@ -323,7 +325,7 @@ def test_argcomplete(testdir, monkeypatch) -> None:
323
325
arg = "--fu"
324
326
monkeypatch .setenv ("COMP_LINE" , "pytest " + arg )
325
327
monkeypatch .setenv ("COMP_POINT" , str (len ("pytest " + arg )))
326
- result = testdir .run ("bash" , str (script ), arg )
328
+ result = pytester .run ("bash" , str (script ), arg )
327
329
if result .ret == 255 :
328
330
# argcomplete not found
329
331
pytest .skip ("argcomplete not available" )
@@ -339,5 +341,5 @@ def test_argcomplete(testdir, monkeypatch) -> None:
339
341
arg = "test_argc"
340
342
monkeypatch .setenv ("COMP_LINE" , "pytest " + arg )
341
343
monkeypatch .setenv ("COMP_POINT" , str (len ("pytest " + arg )))
342
- result = testdir .run ("bash" , str (script ), arg )
344
+ result = pytester .run ("bash" , str (script ), arg )
343
345
result .stdout .fnmatch_lines (["test_argcomplete" , "test_argcomplete.d/" ])
0 commit comments