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

fix: correctly separate command-line arguments in tox-to-nox #906

Merged
merged 1 commit into from
Jan 3, 2025
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
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()
)