From e2ec5135067be9edd7ed3ee13e46a59e3a6f54f6 Mon Sep 17 00:00:00 2001 From: chiri Date: Fri, 3 Jan 2025 07:22:15 +0300 Subject: [PATCH] fix `tox-to-nox` correctly separate the command-line arguments (#906) --- nox/tox_to_nox.py | 7 ++++++- tests/test_tox_to_nox.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/nox/tox_to_nox.py b/nox/tox_to_nox.py index 087585d6..088f6664 100644 --- a/nox/tox_to_nox.py +++ b/nox/tox_to_nox.py @@ -116,7 +116,12 @@ def main() -> None: wrapjoin(c.split()) for c in section["commands"].strip().splitlines() ] - config[name]["deps"] = wrapjoin(section["deps"].strip().splitlines()) + config[name]["deps"] = wrapjoin([ + part for dep + in section["deps"].strip().splitlines() + for part in + (dep.split() if dep.startswith("-r") else [dep]) + ]) for option in "skip_install", "use_develop": if section.get(option): diff --git a/tests/test_tox_to_nox.py b/tests/test_tox_to_nox.py index 4146ea47..24885e3c 100644 --- a/tests/test_tox_to_nox.py +++ b/tests/test_tox_to_nox.py @@ -357,3 +357,33 @@ def lint(session): """ ).lstrip() ) + + +def test_commands_with_requirements(makeconfig: Callable[[str], str]) -> None: + result = makeconfig( + textwrap.dedent(""" + [tox] + envlist = aiohttp + + [testenv] + use_develop = true + deps = + pytest + pytest-cov + aiohttp: -r requirements/aiohttp.txt + """ + ) + ) + + assert ( + result + == textwrap.dedent(""" + import nox + + + @nox.session(python='python3.13') + def aiohttp(session): + session.install('pytest', 'pytest-cov', '-r', 'requirements/aiohttp.txt') + session.install('-e', '.') + """).lstrip() + )