Skip to content

Commit

Permalink
fix tox-to-nox correctly separate the command-line arguments (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
chirizxc authored Jan 3, 2025
1 parent c47dd27 commit e2ec513
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nox/tox_to_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
30 changes: 30 additions & 0 deletions tests/test_tox_to_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)

0 comments on commit e2ec513

Please sign in to comment.