MCPcopy Index your code
hub / github.com/pytest-dev/pytest / test_tmp_path_always_is_realpath

Function test_tmp_path_always_is_realpath

testing/test_tmpdir.py:326–344  ·  view source on GitHub ↗
(pytester: Pytester, monkeypatch)

Source from the content-addressed store, hash-verified

324
325
326def test_tmp_path_always_is_realpath(pytester: Pytester, monkeypatch) -> None:
327 # the reason why tmp_path should be a realpath is that
328 # when you cd to it and do "os.getcwd()" you will anyway
329 # get the realpath. Using the symlinked path can thus
330 # easily result in path-inequality
331 # XXX if that proves to be a problem, consider using
332 # os.environ["PWD"]
333 realtemp = pytester.mkdir("myrealtemp")
334 linktemp = pytester.path.joinpath("symlinktemp")
335 attempt_symlink_to(linktemp, str(realtemp))
336 monkeypatch.setenv("PYTEST_DEBUG_TEMPROOT", str(linktemp))
337 pytester.makepyfile(
338 """
339 def test_1(tmp_path):
340 assert tmp_path.resolve() == tmp_path
341 """
342 )
343 reprec = pytester.inline_run()
344 reprec.assertoutcome(passed=1)
345
346
347def test_tmp_path_too_long_on_parametrization(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 6

setenvMethod · 0.80
assertoutcomeMethod · 0.80
attempt_symlink_toFunction · 0.70
mkdirMethod · 0.45
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…