MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_tmp_path_always_is_realpath

Function test_tmp_path_always_is_realpath

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

Source from the content-addressed store, hash-verified

119
120
121def test_tmp_path_always_is_realpath(pytester: Pytester, monkeypatch) -> None:
122 # the reason why tmp_path should be a realpath is that
123 # when you cd to it and do "os.getcwd()" you will anyway
124 # get the realpath. Using the symlinked path can thus
125 # easily result in path-inequality
126 # XXX if that proves to be a problem, consider using
127 # os.environ["PWD"]
128 realtemp = pytester.mkdir("myrealtemp")
129 linktemp = pytester.path.joinpath("symlinktemp")
130 attempt_symlink_to(linktemp, str(realtemp))
131 monkeypatch.setenv("PYTEST_DEBUG_TEMPROOT", str(linktemp))
132 pytester.makepyfile(
133 """
134 def test_1(tmp_path):
135 assert tmp_path.resolve() == tmp_path
136 """
137 )
138 reprec = pytester.inline_run()
139 reprec.assertoutcome(passed=1)
140
141
142def 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