pytest-dev#8204 migrate some tests to tmp_path fixture (#8209)
migrating some tests from tmpdir to tmp_path fixture
This commit is contained in:
		
							parent
							
								
									5f11a35b99
								
							
						
					
					
						commit
						20c59e3aa4
					
				|  | @ -364,12 +364,12 @@ def test_excinfo_no_sourcecode(): | |||
|     assert s == "  File '<string>':1 in <module>\n  ???\n" | ||||
| 
 | ||||
| 
 | ||||
| def test_excinfo_no_python_sourcecode(tmpdir): | ||||
| def test_excinfo_no_python_sourcecode(tmp_path: Path) -> None: | ||||
|     # XXX: simplified locally testable version | ||||
|     tmpdir.join("test.txt").write("{{ h()}}:") | ||||
|     tmp_path.joinpath("test.txt").write_text("{{ h()}}:") | ||||
| 
 | ||||
|     jinja2 = pytest.importorskip("jinja2") | ||||
|     loader = jinja2.FileSystemLoader(str(tmpdir)) | ||||
|     loader = jinja2.FileSystemLoader(str(tmp_path)) | ||||
|     env = jinja2.Environment(loader=loader) | ||||
|     template = env.get_template("test.txt") | ||||
|     excinfo = pytest.raises(ValueError, template.render, h=h) | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| import subprocess | ||||
| import sys | ||||
| from pathlib import Path | ||||
| 
 | ||||
| import pytest | ||||
| from _pytest.monkeypatch import MonkeyPatch | ||||
| 
 | ||||
| # Test for _argcomplete but not specific for any application. | ||||
| 
 | ||||
|  | @ -65,19 +67,22 @@ class FilesCompleter: | |||
| 
 | ||||
| class TestArgComplete: | ||||
|     @pytest.mark.skipif("sys.platform in ('win32', 'darwin')") | ||||
|     def test_compare_with_compgen(self, tmpdir): | ||||
|     def test_compare_with_compgen( | ||||
|         self, tmp_path: Path, monkeypatch: MonkeyPatch | ||||
|     ) -> None: | ||||
|         from _pytest._argcomplete import FastFilesCompleter | ||||
| 
 | ||||
|         ffc = FastFilesCompleter() | ||||
|         fc = FilesCompleter() | ||||
| 
 | ||||
|         with tmpdir.as_cwd(): | ||||
|             assert equal_with_bash("", ffc, fc, out=sys.stdout) | ||||
|         monkeypatch.chdir(tmp_path) | ||||
| 
 | ||||
|             tmpdir.ensure("data") | ||||
|         assert equal_with_bash("", ffc, fc, out=sys.stdout) | ||||
| 
 | ||||
|             for x in ["d", "data", "doesnotexist", ""]: | ||||
|                 assert equal_with_bash(x, ffc, fc, out=sys.stdout) | ||||
|         tmp_path.cwd().joinpath("data").touch() | ||||
| 
 | ||||
|         for x in ["d", "data", "doesnotexist", ""]: | ||||
|             assert equal_with_bash(x, ffc, fc, out=sys.stdout) | ||||
| 
 | ||||
|     @pytest.mark.skipif("sys.platform in ('win32', 'darwin')") | ||||
|     def test_remove_dir_prefix(self): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue