| 297 | @dec.skip_win32 # can't create not-user-writable dir on win |
| 298 | @with_environment |
| 299 | def 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 |