Reputation: 989
I am trying to call pytest in Python code using the following code. The code works fine.
args = ['test_folder_name', '--junitxml=output.xml', '--ignore=file_to_ignore.py']
ret_code = pytest.main(args)
However, it throws errors if I add double quotes around the file paths in the options:
args = ['test_folder_name', '--junitxml="output.xml"', '--ignore="file_to_ignore.py"']
ret_code = pytest.main(args)
When I call pytest in command line I am able to specify the option as --junitxml=”somepath” and this allows somepath to contain spaces. Why I can't do the same thing when calling pytest.main in Python code?
Upvotes: 1
Views: 200
Reputation: 362657
Those quotes are handled by the shell. Since you're not calling through the shell when using pytest.main
, you don't need them at all.
If you add them, you will literally have quotes in your input, which can cause an error.
Either of these should work:
args = [..., '--ignore', 'file to ignore', ...]
args = [..., '--ignore=file to ignore', ...]
Upvotes: 2