|
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 |
@@ -137,24 +138,40 @@ def test_install_quiet(self, tmp_path: pathlib.Path, run_cli, capsys): |
137 | 138 | assert res.out == "" |
138 | 139 |
|
139 | 140 | @pytest.mark.slow |
140 | | - def test_install_import(self, virtualenv): |
141 | | - virtualenv.install_package(os.path.abspath(".")) |
142 | | - assert "basilisp" in virtualenv.installed_packages().keys() |
143 | | - lpy_file = virtualenv.workspace / "boottest.lpy" |
| 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 | + basilisp_path = venv_path / "Scripts" / "basilisp" |
| 146 | + if sys.platform == "win32": |
| 147 | + pip_path = venv_path / "Scripts" / "pip.exe" |
| 148 | + python_path = venv_path / "Scripts" / "python.exe" |
| 149 | + else: |
| 150 | + pip_path = venv_path / "bin" / "pip" |
| 151 | + python_path = venv_path / "bin" / "python" |
| 152 | + |
| 153 | + cmd = [pip_path, "install", "."] |
| 154 | + result = subprocess.run(cmd, capture_output=True, text=True, cwd=os.getcwd()) |
| 155 | + |
| 156 | + lpy_file = tmp_path / "boottest.lpy" |
144 | 157 | lpy_file.write_text("(ns boottest) (defn abc [] (println (+ 155 4)))") |
145 | 158 |
|
146 | | - cmd = 'python -c "import boottest; boottest.abc()"' |
147 | | - try: |
148 | | - should_fail = virtualenv.run(cmd, capture=True) |
149 | | - assert False, should_fail |
150 | | - except subprocess.CalledProcessError as e: |
151 | | - print(f"Command failed as expected, with exit code {e.returncode}") |
| 159 | + cmd_import = [python_path, "-c", "import boottest; boottest.abc()"] |
| 160 | + result = subprocess.run( |
| 161 | + cmd_import, capture_output=True, text=True, cwd=tmp_path |
| 162 | + ) |
| 163 | + assert "No module named 'boottest'" in result.stderr, result |
152 | 164 |
|
153 | | - bs = virtualenv.run("basilisp bootstrap", capture=True) |
154 | | - assert "Your Python installation has been bootstrapped!" in bs |
| 165 | + cmd = [basilisp_path, "bootstrap"] |
| 166 | + result = subprocess.run(cmd, capture_output=True, text=True, cwd=tmp_path) |
| 167 | + assert ( |
| 168 | + "Your Python installation has been bootstrapped!" in result.stdout |
| 169 | + ), result |
155 | 170 |
|
156 | | - after = virtualenv.run(cmd, capture=True) |
157 | | - assert after.startswith("159") |
| 171 | + result = subprocess.run( |
| 172 | + cmd_import, capture_output=True, text=True, cwd=tmp_path |
| 173 | + ) |
| 174 | + assert result.stdout.strip() == "159", result |
158 | 175 |
|
159 | 176 | def test_nothing_to_uninstall(self, tmp_path: pathlib.Path, run_cli, capsys): |
160 | 177 | bootstrap_file = tmp_path / "basilispbootstrap.pth" |
|
0 commit comments