-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Tox not stripping ticks from paths in commands anymore #2635
Comments
Thanks for your report. What happens when you leave out the quotes? Having a look at pytest's documentation, they do not propose using them: |
Just checked on the console with minimal options. pytest is working with and without ticks: But when i execute this: |
This is one of those where you might be better off just removing the quotes, tox will take care not to need them 🤔 |
But ticks are needed if there's spaces in the file names, that's their whole purpose. tox is just not allowed to additionally escape them. |
|
I see that |
Another reason why ticks were/would be nice is that they allow writing commands in ExampleFor example, in the reproducer for #2778 one way to fix the issue with tox >=4 is to remove the quotes from a src:tox-windows-issue$ coverage report --include=tox_windows_issue/*
zsh: no matches found: --include=tox_windows_issue/* That is, in zsh we'd like the quotes (to avoid the shell trying to expand the wildcard): src:tox-windows-issue$ coverage report --include="tox_windows_issue/*"
Name Stmts Miss Cover
---------------------------------------------------
tox_windows_issue/__init__.py 5 0 100%
---------------------------------------------------
TOTAL 5 0 100% There is of course another way to escape the wildcard with a backslash: src:tox-windows-issue$ coverage report --include=tox_windows_issue/\*
Name Stmts Miss Cover
---------------------------------------------------
tox_windows_issue/__init__.py 5 0 100%
---------------------------------------------------
TOTAL 5 0 100% That one works both in zsh and in the aforementioned reproducer (this job). But then |
You're free to put in a PR to fix this 👍 |
I wish there were room for it in my roadmap, but I must pass on that opportunity to graduate from tox user to contributor 😃 I hope the feedback will help though! Either for project maintainers, or future travelers who run into similar issues (e.g. "why did my CI start to break?") and can find a documented path to the quote-stripping change. |
for less surprises, stick to shlex POSIX mode, regardless of the running platform. on win32 platforms, do not use backslash escape to make it easier to work with windows style paths that use backslash as the separator fix tox-dev#2635
for less surprises, stick to shlex POSIX mode, regardless of the running platform. on win32 platforms, explicitly convert a single backslash to double backslash, unless the following character is "special" fix tox-dev#2635 str_convert fixup
for less surprises, stick to shlex POSIX mode, regardless of the running platform. on win32 platforms, explicitly convert a single backslash to double backslash, unless the following character is "special" fix tox-dev#2635 str_convert fixup
for less surprises, stick to shlex POSIX mode, regardless of the running platform. on win32 platforms, explicitly convert a single backslash to double backslash, unless the following character is "special" fix tox-dev#2635 str_convert fixup str_convert: always use shlex POSIX mode for less surprises, stick to shlex POSIX mode, regardless of the running platform. on win32 platforms, explicitly convert a single backslash to double backslash, unless the following character is "special" fix tox-dev#2635 str_convert fixup
Fixed in Repro from #2635 (comment) must_pass_1: remove tox env folder C:\Users\masen\code\.tox\must_pass_1
must_pass_1: install_deps> python -I -m pip install pytest
must_pass_1: commands[0]> pytest tests --basetemp=tests/tmp/must_pass_1
================================================= test session starts =================================================
platform win32 -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0
cachedir: .tox\must_pass_1\.pytest_cache
rootdir: C:\Users\masen\code
collected 1 item
tests\unit\test_foo.py . [100%]
================================================== 1 passed in 0.01s ==================================================
must_pass_1: OK ✔ in 7.25 seconds
must_pass_2: remove tox env folder C:\Users\masen\code\.tox\must_pass_2
must_pass_2: install_deps> python -I -m pip install pytest
must_pass_2: commands[0]> pytest tests --basetemp=tests/tmp/must_pass_2
================================================= test session starts =================================================
platform win32 -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0
cachedir: .tox\must_pass_2\.pytest_cache
rootdir: C:\Users\masen\code
collected 1 item
tests\unit\test_foo.py . [100%]
================================================== 1 passed in 0.01s ==================================================
must_pass_2: OK ✔ in 4.91 seconds
must_pass_3: remove tox env folder C:\Users\masen\code\.tox\must_pass_3
must_pass_3: install_deps> python -I -m pip install pytest
must_pass_3: commands[0]> pytest tests "--basetemp=tests/tmp with space/must_pass_3"
================================================= test session starts =================================================
platform win32 -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0
cachedir: .tox\must_pass_3\.pytest_cache
rootdir: C:\Users\masen\code
collected 1 item
tests\unit\test_foo.py . [100%]
================================================== 1 passed in 0.01s ==================================================
must_fail: remove tox env folder C:\Users\masen\code\.tox\must_fail
must_pass_3: OK ✔ in 4.92 seconds
must_fail: install_deps> python -I -m pip install pytest
must_fail: commands[0]> pytest tests --basetemp=tests/tmp with space/must_fail
================================================= test session starts =================================================
platform win32 -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0
cachedir: .tox\must_fail\.pytest_cache
rootdir: C:\Users\masen\code
collected 0 items
================================================ no tests ran in 0.00s ================================================
ERROR: file or directory not found: with
must_fail: exit 4 (1.61 seconds) C:\Users\masen\code> pytest tests --basetemp=tests/tmp with space/must_fail pid=15532
must_pass_1: OK (7.25=setup[6.03]+cmd[1.22] seconds)
must_pass_2: OK (4.91=setup[4.03]+cmd[0.88] seconds)
must_pass_3: OK (4.92=setup[4.03]+cmd[0.89] seconds)
must_fail: FAIL code 4 (5.64=setup[4.03]+cmd[1.61] seconds)
evaluation failed :( (22.81 seconds) |
Issue
I have a tox test env which calls pytest like this:
As you can see the paths are wrapped in ticks.
When running the tox env via tox<4.0.0, apparently the ticks get stripped before passing it to the pytest subprocess so there is NO problem.
Here a print of the arguments inside
.tox/py39/Lib/site-packages/_pytest/config/__init__.py:306
:ARGS: ['tests/unit', '--in_memory=False', '--basetemp=tests/tmp/py39', '--junitxml=tests/tmp/results/junit-out_memory-py39.xml', '--junit-prefix=DLH5-py-py39']
In tox 4.0.2 however the ticks are not stripped anymore, which results in following arguments passed to pytest:
ARGS: ['tests/unit', '--in_memory=False', '--basetemp="tests/tmp/py39"', '--junitxml="tests/tmp/results/junit-out_memory-py39.xml"', '--junit-prefix="DLH5-py-py39"']
Then pytest fails with following stderr:
The pytest version in both cases is the same 7.2.0.
Since tox 4 is claimed to be backwards compatible I would assume this is a bug in tox.
Environment
The text was updated successfully, but these errors were encountered: