MCPcopy Index your code
hub / github.com/ipython/ipython / test_not_writable_ipdir

Function test_not_writable_ipdir

tests/test_path.py:299–319  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

297@dec.skip_win32 # can't create not-user-writable dir on win
298@with_environment
299def test_not_writable_ipdir():
300 tmpdir = tempfile.mkdtemp()
301 os.name = "posix"
302 env.pop("IPYTHON_DIR", None)
303 env.pop("IPYTHONDIR", None)
304 env.pop("XDG_CONFIG_HOME", None)
305 env["HOME"] = tmpdir
306 ipdir = os.path.join(tmpdir, ".ipython")
307 os.mkdir(ipdir, 0o555)
308 try:
309 open(os.path.join(ipdir, "_foo_"), "w", encoding="utf-8").close()
310 except IOError:
311 pass
312 else:
313 # I can still write to an unwritable dir,
314 # assume I'm root and skip the test
315 pytest.skip("I can't create directories that I can't write to")
316
317 with pytest.warns(UserWarning, match="is not a writable location"):
318 ipdir = paths.get_ipython_dir()
319 env.pop("IPYTHON_DIR", None)
320
321
322@with_environment

Callers

nothing calls this directly

Calls 2

popMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…