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

Runner argument not parsed correctly on windows #126

Open
MaxumCSmith opened this issue Jun 15, 2022 · 1 comment
Open

Runner argument not parsed correctly on windows #126

MaxumCSmith opened this issue Jun 15, 2022 · 1 comment

Comments

@MaxumCSmith
Copy link

MaxumCSmith commented Jun 15, 2022

Upon running the following command,

$ poetry run poe test-integ-watch
Poe => ptw --runner "pytest -m integtest"

[Wed Jun 15 10:02:38 2022] Running: "pytest -m integtest"
'\"pytest -m integtest\"' is not recognized as an internal or external command,
operable program or batch file.

my windows machine produces an argv that is formed as
['"poetry', 'run', 'poe', 'test-integ"'] instead of being formed as ['poetry', 'run', 'poe', 'test-integ']. The line where the watcher fails is shown below.

found at

p = subprocess.Popen(argv, shell=is_windows)

Running the same command on a Mac would have a well-formed list of arguments.

One possible solution would be to clean the arguments before passing them into the constructor, i.e.,

def cleanArgv(argv):
  return [x.replace('\"', '') for x in argv]

argv = cleanArgv(argv) if is_windows else argv

# Run tests
p = subprocess.Popen(argv, shell=is_windows)
@MaxumCSmith MaxumCSmith changed the title subprocess arguments not parsed correctly on windows Runner argument not parsed correctly on windows Jun 16, 2022
@mrtndwrd
Copy link

mrtndwrd commented Nov 19, 2024

This seems to still be broken. Any way around this? I'd specifically love to be able to run ptw with -m or -k arguments on Windows (unfortunately my current project has to run on a Windows machine, not WSL or anything else).

To add to this, the problem also seems to occur if you use the recommended -- <pytest runner arguments> method:

poetry run ptw -- -m "not integration"
Usage: ptw [options] [--ignore <dir>...] [<directory>...] [-- <pytest-args>...]

Edit: the workaround for me seems to be to not use poetry run to run the command. If I activate the Poetry env first and just run ptw -- -m "not integration" all is good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants