|
1 | 1 | import subprocess
|
2 | 2 | import sys
|
| 3 | +from pathlib import Path |
3 | 4 |
|
4 | 5 | import pytest
|
| 6 | +from _pytest.monkeypatch import MonkeyPatch |
5 | 7 |
|
6 | 8 | # Test for _argcomplete but not specific for any application.
|
7 | 9 |
|
@@ -65,19 +67,22 @@ def __call__(self, prefix, **kwargs):
|
65 | 67 |
|
66 | 68 | class TestArgComplete:
|
67 | 69 | @pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
68 |
| - def test_compare_with_compgen(self, tmpdir): |
| 70 | + def test_compare_with_compgen( |
| 71 | + self, tmp_path: Path, monkeypatch: MonkeyPatch |
| 72 | + ) -> None: |
69 | 73 | from _pytest._argcomplete import FastFilesCompleter
|
70 | 74 |
|
71 | 75 | ffc = FastFilesCompleter()
|
72 | 76 | fc = FilesCompleter()
|
73 | 77 |
|
74 |
| - with tmpdir.as_cwd(): |
75 |
| - assert equal_with_bash("", ffc, fc, out=sys.stdout) |
| 78 | + monkeypatch.chdir(tmp_path) |
76 | 79 |
|
77 |
| - tmpdir.ensure("data") |
| 80 | + assert equal_with_bash("", ffc, fc, out=sys.stdout) |
78 | 81 |
|
79 |
| - for x in ["d", "data", "doesnotexist", ""]: |
80 |
| - assert equal_with_bash(x, ffc, fc, out=sys.stdout) |
| 82 | + tmp_path.cwd().joinpath("data").touch() |
| 83 | + |
| 84 | + for x in ["d", "data", "doesnotexist", ""]: |
| 85 | + assert equal_with_bash(x, ffc, fc, out=sys.stdout) |
81 | 86 |
|
82 | 87 | @pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
83 | 88 | def test_remove_dir_prefix(self):
|
|
0 commit comments