|
11 | 11 | import pytest
|
12 | 12 |
|
13 | 13 | from jupyter_core import migrate as migrate_mod
|
| 14 | +from jupyter_core.application import JupyterApp |
14 | 15 | from jupyter_core.migrate import (
|
15 | 16 | migrate,
|
16 | 17 | migrate_config,
|
@@ -53,7 +54,7 @@ def env(request):
|
53 | 54 | def fin():
|
54 | 55 | """Cleanup test env"""
|
55 | 56 | env_patch.stop()
|
56 |
| - shutil.rmtree(td) |
| 57 | + shutil.rmtree(td, ignore_errors=os.name == 'nt') |
57 | 58 |
|
58 | 59 | request.addfinalizer(fin)
|
59 | 60 |
|
@@ -216,3 +217,31 @@ def test_migrate(env):
|
216 | 217 | migrate()
|
217 | 218 | assert os.path.exists(env["JUPYTER_CONFIG_DIR"])
|
218 | 219 | assert os.path.exists(env["JUPYTER_DATA_DIR"])
|
| 220 | + |
| 221 | + |
| 222 | +def test_app_migrate(env): |
| 223 | + shutil.copytree(dotipython, env["IPYTHONDIR"]) |
| 224 | + app = JupyterApp() |
| 225 | + app.initialize([]) |
| 226 | + assert os.path.exists(env["JUPYTER_CONFIG_DIR"]) |
| 227 | + assert os.path.exists(env["JUPYTER_DATA_DIR"]) |
| 228 | + |
| 229 | + |
| 230 | +def test_app_migrate_skip_if_marker(env): |
| 231 | + shutil.copytree(dotipython, env["IPYTHONDIR"]) |
| 232 | + touch(pjoin(env["JUPYTER_CONFIG_DIR"], "migrated"), "done") |
| 233 | + app = JupyterApp() |
| 234 | + app.initialize([]) |
| 235 | + assert os.listdir(env["JUPYTER_CONFIG_DIR"]) == ["migrated"] |
| 236 | + assert not os.path.exists(env["JUPYTER_DATA_DIR"]) |
| 237 | + |
| 238 | + |
| 239 | +def test_app_migrate_skip_unwritable_marker(env): |
| 240 | + shutil.copytree(dotipython, env["IPYTHONDIR"]) |
| 241 | + migrated_marker = pjoin(env["JUPYTER_CONFIG_DIR"], "migrated") |
| 242 | + touch(migrated_marker, "done") |
| 243 | + os.chmod(migrated_marker, 0) # make it unworkable |
| 244 | + app = JupyterApp() |
| 245 | + app.initialize([]) |
| 246 | + assert os.listdir(env["JUPYTER_CONFIG_DIR"]) == ["migrated"] |
| 247 | + assert not os.path.exists(env["JUPYTER_DATA_DIR"]) |
0 commit comments