Open zhihaoy opened 2 years ago
Can you show the exact way you invoke pytest
?
Can you show the exact way you invoke
pytest
?
Passing this array to subprocess.call
['c:\\python\\python.exe', '-m', 'pytest', '-v', '--some_custom_option', '--many_other_custom_options', '--engines_dir=C:\\The\\Argument\\We\\Passed\\To\\This\\Option', '-k', 'key1 or key2', '-m', 'not criteria1']
I haven't tried running this command in cmd, but I doubt that will make a difference.
If you split '--engines_dir=C:\\The\\Argument\\We\\Passed\\To\\This\\Option'
into two separate arguments '--engines_dir', 'C:\\The\\Argument\\We\\Passed\\To\\This\\Option'
does it still happen?
Please investigate what's happening if you pass the path value of the arguments to pathlib.Path
As the install location of the python doesn't match the filename I'd expect, details on what type of python this is would be highly appreciated
If you split
'--engines_dir=C:\\The\\Argument\\We\\Passed\\To\\This\\Option'
into two separate arguments'--engines_dir', 'C:\\The\\Argument\\We\\Passed\\To\\This\\Option'
does it still happen?
No, this works without an issue. However, I must convert all the options to use this style, otherwise, I get an error from pytest's __main__
.
Please investigate what's happening if you pass the path value of the arguments to pathlib.Path
Nothing special, the path is a valid path, and I got a valid WindowsPath
back. The defective paths have spaces inside, though.
As the install location of the python doesn't match the filename I'd expect, details on what type of python this is would be highly appreciated
An official Python 3.8.8 installer was used, installed to a non-default location.
Now I figured out when the issue happens. It only reproduces with Python 3.8.8. It does not reproduce with Python 3.8.10. The install location / whether virtualenv is used does not matter.
I have a similar or exactly this problem. I prepared a small test case: https://github.com/phdru/pytest3-w64-conftest . It works on Linux, it works on Windows with Python 2.7 and 3.5, but started to fail on Windows with Python 3.6+. This is a test run: https://github.com/phdru/pytest3-w64-conftest/actions/runs/3074106082 . The command (ran from tox
) is pytest -D "mysql://localhost/test?fest=pest"
. The full traceback is:
Traceback (most recent call last):
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\Scripts\pytest.EXE\__main__.py", line 7, in <module>
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 187, in console_main
code = main()
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 145, in main
config = _prepareconfig(args, plugins)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 325, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_callers.py", line 55, in _multicall
gen.send(outcome)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\helpconfig.py", line 102, in pytest_cmdline_parse
config: Config = outcome.get_result()
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_result.py", line 60, in get_result
raise ex[1].with_traceback(ex[2])
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
res = hook_impl.function(*args)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 1017, in pytest_cmdline_parse
self.parse(args)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 1305, in parse
self._preparse(args, addopts=addopts)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 1208, in _preparse
early_config=self, args=args, parser=self._parser
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
return outcome.get_result()
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_result.py", line 60, in get_result
raise ex[1].with_traceback(ex[2])
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
res = hook_impl.function(*args)
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 1085, in pytest_load_initial_conftests
early_config.known_args_namespace, rootpath=early_config.rootpath
File "D:\a\pytest3-w64-conftest\pytest3-w64-conftest\.tox\py37\lib\site-packages\_pytest\config\__init__.py", line 528, in _set_initial_conftests
if anchor.exists(): # we found some file object
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\pathlib.py", line 1361, in exists
self.stat()
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\pathlib.py", line 1183, in stat
return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'D:\\a\\pytest3-w64-conftest\\pytest3-w64-conftest\\mysql:\\localhost\\test?fest=pest'
pip list
from the virtual environment you are usingThe option is added in using
in
conftest.py
.Result:
Installed packages:
OS: Windows 10 Enterprise TH2 SP1 64bit