Skip to content

Commit e1affe2

Browse files
committed
replace pytest_virtualenv with venv module direct calls
1 parent a98d8e0 commit e1affe2

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ sphinx-copybutton = "^0.5.2"
5656
sphinxext-opengraph = "^v0.9.1"
5757
furo = "^2023.08.19"
5858
tox = "*"
59-
pytest-virtualenv = "^1.8.1"
6059

6160
[tool.poetry.extras]
6261
pygments = ["pygments"]

tests/basilisp/cli_test.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import tempfile
1212
import time
13+
import venv
1314
from collections.abc import Sequence
1415
from threading import Thread
1516
from typing import Optional
@@ -137,24 +138,40 @@ def test_install_quiet(self, tmp_path: pathlib.Path, run_cli, capsys):
137138
assert res.out == ""
138139

139140
@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"
144157
lpy_file.write_text("(ns boottest) (defn abc [] (println (+ 155 4)))")
145158

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
152164

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
155170

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
158175

159176
def test_nothing_to_uninstall(self, tmp_path: pathlib.Path, run_cli, capsys):
160177
bootstrap_file = tmp_path / "basilispbootstrap.pth"

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ deps =
1212
coverage[toml]
1313
pytest >=7.0.0,<9.0.0
1414
pytest-xdist >=3.6.1,<4.0.0
15-
pytest-virtualenv
1615
pygments
1716
commands =
1817
coverage run \
@@ -22,7 +21,7 @@ commands =
2221
--import-mode=importlib \
2322
--junitxml={toxinidir}/junit/pytest/{envname}.xml \
2423
# also enable pytest marked as slow \
25-
--run-slow \
24+
--run-slow \
2625
{posargs}
2726

2827
[testenv:coverage]

0 commit comments

Comments
 (0)