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"
|
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
|
# XXX: simplified locally testable version
|
||||||
tmpdir.join("test.txt").write("{{ h()}}:")
|
tmp_path.joinpath("test.txt").write_text("{{ h()}}:")
|
||||||
|
|
||||||
jinja2 = pytest.importorskip("jinja2")
|
jinja2 = pytest.importorskip("jinja2")
|
||||||
loader = jinja2.FileSystemLoader(str(tmpdir))
|
loader = jinja2.FileSystemLoader(str(tmp_path))
|
||||||
env = jinja2.Environment(loader=loader)
|
env = jinja2.Environment(loader=loader)
|
||||||
template = env.get_template("test.txt")
|
template = env.get_template("test.txt")
|
||||||
excinfo = pytest.raises(ValueError, template.render, h=h)
|
excinfo = pytest.raises(ValueError, template.render, h=h)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from _pytest.monkeypatch import MonkeyPatch
|
||||||
|
|
||||||
# Test for _argcomplete but not specific for any application.
|
# Test for _argcomplete but not specific for any application.
|
||||||
|
|
||||||
|
@ -65,19 +67,22 @@ class FilesCompleter:
|
||||||
|
|
||||||
class TestArgComplete:
|
class TestArgComplete:
|
||||||
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
@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
|
from _pytest._argcomplete import FastFilesCompleter
|
||||||
|
|
||||||
ffc = FastFilesCompleter()
|
ffc = FastFilesCompleter()
|
||||||
fc = FilesCompleter()
|
fc = FilesCompleter()
|
||||||
|
|
||||||
with tmpdir.as_cwd():
|
monkeypatch.chdir(tmp_path)
|
||||||
assert equal_with_bash("", ffc, fc, out=sys.stdout)
|
|
||||||
|
|
||||||
tmpdir.ensure("data")
|
assert equal_with_bash("", ffc, fc, out=sys.stdout)
|
||||||
|
|
||||||
for x in ["d", "data", "doesnotexist", ""]:
|
tmp_path.cwd().joinpath("data").touch()
|
||||||
assert equal_with_bash(x, ffc, fc, out=sys.stdout)
|
|
||||||
|
for x in ["d", "data", "doesnotexist", ""]:
|
||||||
|
assert equal_with_bash(x, ffc, fc, out=sys.stdout)
|
||||||
|
|
||||||
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
||||||
def test_remove_dir_prefix(self):
|
def test_remove_dir_prefix(self):
|
||||||
|
|
Loading…
Reference in New Issue