Skip to content

Commit 145dc85

Browse files
committed
Update virtual env management in unit tests for Poetry 2.0
1 parent eda1848 commit 145dc85

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import os
22
from tempfile import TemporaryDirectory
33
from typing import Iterator
4+
from unittest.mock import patch
45

56
import pytest
67

78

9+
@pytest.fixture(scope="session", autouse=True)
10+
def subprocess_environment() -> Iterator[None]:
11+
with patch.dict(os.environ, {}) as patched_env:
12+
if "VIRTUAL_ENV" in patched_env:
13+
del patched_env["VIRTUAL_ENV"]
14+
yield
15+
16+
817
def pytest_addoption(parser: pytest.Parser) -> None:
918
group = parser.getgroup("cookie", "python-cookie test helpers")
1019
group.addoption(

tests/test_new_cookie.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ def test_new_cookie_create(temp_dir: str) -> None:
4040
), "Untracked files present in template-rendered project"
4141

4242
# Verify cruft is up to date
43-
subprocess.check_call(["poetry", "run", "pip", "install", "toml"])
43+
subprocess.check_call(
44+
["poetry", "run", "pip", "install", "toml"], cwd=project_dir
45+
)
4446
subprocess.check_call(
4547
["poetry", "run", "cruft", "diff", "--exit-code"], cwd=project_dir
4648
)
4749

4850
# Install rendered project
49-
subprocess.check_call(["poetry", "install"], cwd=project_dir)
51+
subprocess.check_call(["poetry", "sync"], cwd=project_dir)
5052
# Run rendered project's tests
5153
subprocess.check_call(["poetry", "run", "poe", "test"], cwd=project_dir)
5254
# Build container for rendered project

0 commit comments

Comments
 (0)