【问题标题】:PyTest throws [WinError 87] parameter not foundPyTest 抛出 [WinError 87] 参数未找到
【发布时间】:2023-03-31 16:46:01
【问题描述】:

我目前正在使用 Python 进行测试自动化。我试图使用 Allure,它首先需要 Pytest。安装完这两个模块后,我继续调用:

pytest --alluredir $OutputPath

但收到 [WinError 87] 参数未找到消息。为了确认 Allure 没有导致问题,然后我尝试仅通过 Python 解释器从命令行调用 Pytest:

python -m pytest

但仍然出现同样的错误。在网上看,这个错误已经发生了一段时间,但我似乎找不到答案。 我正在使用这些版本:

Python-> 3.7.4

Pytest-> 5.2.1

IDE----->Visual Studio 代码

操作系统----->Windows 7

完整追溯:

Traceback (most recent call last):
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\c.hernandezperez\AppData\Local\Continuum\anaconda3\Scripts\pytest.exe\__main__.py", line 9, in <module>
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\config.py", line 54, in main
    config = _prepareconfig(args, plugins)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\config.py", line 167, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\callers.py", line 196, in _multicall
    gen.send(outcome)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\callers.py", line 76, in get_result
    raise ex[1].with_traceback(ex[2])
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\config.py", line 981, in pytest_cmdline_parse
    self.parse(args)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\config.py", line 1146, in parse
    self._preparse(args, addopts=addopts)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\config.py", line 1108, in _preparse
    early_config=self, args=args, parser=self._parser
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\callers.py", line 201, in _multicall
    return outcome.get_result()
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\callers.py", line 76, in get_result
    raise ex[1].with_traceback(ex[2])
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\pluggy\callers.py", line 175, in _multicall
    next(gen)   # first yield
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\capture.py", line 46, in pytest_load_initial_conftests
    _py36_windowsconsoleio_workaround(sys.stdout)
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\capture.py", line 711, in _py36_windowsconsoleio_workaround
    sys.__stdin__ = sys.stdin = _reopen_stdio(sys.stdin, "rb")
  File "c:\users\c.hernandezperez\appdata\local\continuum\anaconda3\lib\site-packages\_pytest\capture.py", line 704, in _reopen_stdio
    open(os.dup(f.fileno()), mode, buffering),
OSError: [WinError 87] El parámetro no es correcto

【问题讨论】:

    标签: python-3.x automation automated-tests pytest


    【解决方案1】:

    this GitHub question 所述,显然 Python 3.7.4 不适用于 Pytest。因此,该问题被视为已回答。

    【讨论】:

      猜你喜欢
      • 2021-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-29
      • 2022-01-21
      • 2019-12-21
      • 1970-01-01
      相关资源
      最近更新 更多