Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set TMPDIR when exporting to requirements.txt #298

Merged
merged 4 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def tests(session: Session) -> None:
session.install("dataclasses")

try:
session.env.pop("TMPDIR", None)
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
finally:
if session.interactive:
Expand Down
4 changes: 3 additions & 1 deletion src/nox_poetry/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def export_requirements(self) -> Path:
Returns:
The path to the requirements file.
"""
tmpdir = Path(self.session.create_tmp())
tmpdir = Path(self.session.virtualenv.location) / "tmp"
tmpdir.mkdir(exist_ok=True)

path = tmpdir / "requirements.txt"
hashfile = tmpdir / f"{path.name}.hash"

Expand Down
15 changes: 9 additions & 6 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
from nox.sessions import Session


class FakeVirtualenv:
"""Fake virtual environment."""

def __init__(self, path: Path) -> None:
"""Initialize."""
self.location = str(path)


class FakeSession:
"""Fake session."""

def __init__(self, path: Path) -> None:
"""Initialize."""
self.path = path
self.virtualenv = FakeVirtualenv(path)

def run(self, *args: str, **kargs: Any) -> str:
"""Run."""
Expand All @@ -23,11 +31,6 @@ def run(self, *args: str, **kargs: Any) -> str:

def install(self, *args: str, **kargs: Any) -> None:
"""Install."""
pass

def create_tmp(self, *args: str, **kargs: Any) -> str:
"""Create temporary directory."""
return str(self.path)


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def proxy(session: nox.Session) -> nox_poetry.Session:

def test_session_getattr(proxy: nox_poetry.Session) -> None:
"""It delegates to the real session."""
assert proxy.create_tmp()
# Fixed in https://github.com/theacodes/nox/pull/377
assert proxy.virtualenv.location # type: ignore[attr-defined]


def test_session_install(proxy: nox_poetry.Session) -> None:
Expand Down