|
1 | 1 | import os |
| 2 | +import pathlib |
2 | 3 | import subprocess |
3 | 4 | import sys |
4 | 5 | import textwrap |
@@ -73,3 +74,45 @@ def test_install_latest(): |
73 | 74 | with venv.VirtualEnv() as v: |
74 | 75 | v.install_package("flask") |
75 | 76 | assert v.installed_packages()["Flask"].version != "1.1.1" |
| 77 | + |
| 78 | + |
| 79 | +def test_keep_named_workspace(tmp_path): |
| 80 | + workspace = tmp_path / "new-workspace" |
| 81 | + workspace.mkdir() |
| 82 | + with venv.VirtualEnv(workspace=str(workspace)) as v: |
| 83 | + pass |
| 84 | + assert workspace.exists() |
| 85 | + |
| 86 | + |
| 87 | +def test_really_keep_named_workspace(tmp_path): |
| 88 | + workspace = tmp_path / "new-workspace" |
| 89 | + workspace.mkdir() |
| 90 | + with venv.VirtualEnv(workspace=str(workspace), delete_workspace=False) as v: |
| 91 | + pass |
| 92 | + assert workspace.exists() |
| 93 | + |
| 94 | + |
| 95 | +def test_delete_named_workspace(tmp_path): |
| 96 | + workspace = tmp_path / "new-workspace" |
| 97 | + workspace.mkdir() |
| 98 | + with venv.VirtualEnv(workspace=str(workspace), delete_workspace=True) as v: |
| 99 | + pass |
| 100 | + assert not workspace.exists() |
| 101 | + |
| 102 | + |
| 103 | +def test_delete_unamed_workspace(): |
| 104 | + with venv.VirtualEnv() as v: |
| 105 | + workspace = pathlib.Path(v.workspace) |
| 106 | + assert not workspace.exists() |
| 107 | + |
| 108 | + |
| 109 | +def test_really_delete_unamed_workspace(): |
| 110 | + with venv.VirtualEnv(delete_workspace=True) as v: |
| 111 | + workspace = pathlib.Path(v.workspace) |
| 112 | + assert not workspace.exists() |
| 113 | + |
| 114 | + |
| 115 | +def test_keep_unamed_workspace(): |
| 116 | + with venv.VirtualEnv(delete_workspace=False) as v: |
| 117 | + workspace = pathlib.Path(v.workspace) |
| 118 | + assert workspace.exists() |
0 commit comments