diff --git a/noxfile.py b/noxfile.py index c8c96bfa..c623d312 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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: diff --git a/src/nox_poetry/sessions.py b/src/nox_poetry/sessions.py index fc3603e5..6d1bc050 100644 --- a/src/nox_poetry/sessions.py +++ b/src/nox_poetry/sessions.py @@ -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" diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index b6cf4f54..c0febc9d 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -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_always(self, *args: str, **kargs: Any) -> str: """Run.""" @@ -23,11 +31,6 @@ def run_always(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 diff --git a/tests/unit/test_sessions.py b/tests/unit/test_sessions.py index 135a3fe9..0f25d201 100644 --- a/tests/unit/test_sessions.py +++ b/tests/unit/test_sessions.py @@ -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: