|
10 | 10 | import sys |
11 | 11 | import tempfile |
12 | 12 | import time |
| 13 | +import venv |
13 | 14 | from collections.abc import Sequence |
14 | 15 | from threading import Thread |
15 | 16 | from typing import Optional |
@@ -108,6 +109,7 @@ def test_install(self, tmp_path: pathlib.Path, run_cli): |
108 | 109 | assert bootstrap_file.read_text() == "import basilisp.sitecustomize" |
109 | 110 |
|
110 | 111 | assert res.out == ( |
| 112 | + f"(Added {bootstrap_file})\n\n" |
111 | 113 | "Your Python installation has been bootstrapped! You can undo this at any " |
112 | 114 | "time with with `basilisp bootstrap --uninstall`.\n" |
113 | 115 | ) |
@@ -135,6 +137,41 @@ def test_install_quiet(self, tmp_path: pathlib.Path, run_cli, capsys): |
135 | 137 | res = capsys.readouterr() |
136 | 138 | assert res.out == "" |
137 | 139 |
|
| 140 | + @pytest.mark.slow |
| 141 | + def test_install_import(self, tmp_path: pathlib.Path): |
| 142 | + venv_path = tmp_path / "venv" |
| 143 | + venv.create(venv_path, with_pip=True) |
| 144 | + |
| 145 | + venv_bin = venv_path / ("Scripts" if sys.platform == "win32" else "bin") |
| 146 | + pip_path = venv_bin / "pip" |
| 147 | + python_path = venv_bin / "python" |
| 148 | + basilisp_path = venv_bin / "basilisp" |
| 149 | + |
| 150 | + result = subprocess.run( |
| 151 | + [pip_path, "install", "."], capture_output=True, text=True, cwd=os.getcwd() |
| 152 | + ) |
| 153 | + |
| 154 | + lpy_file = tmp_path / "boottest.lpy" |
| 155 | + lpy_file.write_text("(ns boottest) (defn abc [] (println (+ 155 4)))") |
| 156 | + |
| 157 | + cmd_import = [python_path, "-c", "import boottest; boottest.abc()"] |
| 158 | + result = subprocess.run( |
| 159 | + cmd_import, capture_output=True, text=True, cwd=tmp_path |
| 160 | + ) |
| 161 | + assert "No module named 'boottest'" in result.stderr, result |
| 162 | + |
| 163 | + result = subprocess.run( |
| 164 | + [basilisp_path, "bootstrap"], capture_output=True, text=True, cwd=tmp_path |
| 165 | + ) |
| 166 | + assert ( |
| 167 | + "Your Python installation has been bootstrapped!" in result.stdout |
| 168 | + ), result |
| 169 | + |
| 170 | + result = subprocess.run( |
| 171 | + cmd_import, capture_output=True, text=True, cwd=tmp_path |
| 172 | + ) |
| 173 | + assert result.stdout.strip() == "159", result |
| 174 | + |
138 | 175 | def test_nothing_to_uninstall(self, tmp_path: pathlib.Path, run_cli, capsys): |
139 | 176 | bootstrap_file = tmp_path / "basilispbootstrap.pth" |
140 | 177 | assert not bootstrap_file.exists() |
|
0 commit comments