pytest: pytest failed to run on windows: OSError: [WinError 87]

I’m using a clean virtual env on windows 7 with python 3.7.4, the pytest is always failed with a OSError as below, on the same machine, i have succeeded to run the pytest on same code with a previou python version, is this related to an upgrade with python?

(calculator) D:\workspace\CalculatorLibrary>pytest -h
Traceback (most recent call last):
  File "d:\python37\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python37\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\workspace\calculator\Scripts\pytest.exe\__main__.py", line 9, in <module>
  File "d:\workspace\calculator\lib\site-packages\_pytest\config\__init__.py", line 55, in main
    config = _prepareconfig(args, plugins)
  File "d:\workspace\calculator\lib\site-packages\_pytest\config\__init__.py", line 200, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "d:\workspace\calculator\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "d:\workspace\calculator\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\workspace\calculator\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "d:\workspace\calculator\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "d:\workspace\calculator\lib\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "d:\workspace\calculator\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "d:\workspace\calculator\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "d:\workspace\calculator\lib\site-packages\_pytest\config\__init__.py", line 661, in pytest_cmdline_parse
    self.parse(args)
  File "d:\workspace\calculator\lib\site-packages\_pytest\config\__init__.py", line 869, in parse
    self._preparse(args, addopts=addopts)
  File "d:\workspace\calculator\lib\site-packages\_pytest\config\__init__.py", line 825, in _preparse
    early_config=self, args=args, parser=self._parser
  File "d:\workspace\calculator\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "d:\workspace\calculator\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\workspace\calculator\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "d:\workspace\calculator\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "d:\workspace\calculator\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "d:\workspace\calculator\lib\site-packages\pluggy\callers.py", line 182, in _multicall
    next(gen)  # first yield
  File "d:\workspace\calculator\lib\site-packages\_pytest\capture.py", line 42, in pytest_load_initial_conftests
    _py36_windowsconsoleio_workaround(sys.stdout)
  File "d:\workspace\calculator\lib\site-packages\_pytest\capture.py", line 815, in _py36_windowsconsoleio_workaround
    sys.stdin = _reopen_stdio(sys.stdin, "rb")
  File "d:\workspace\calculator\lib\site-packages\_pytest\capture.py", line 808, in _reopen_stdio
    open(os.dup(f.fileno()), mode, buffering),
OSError: [WinError 87] 参数错误。

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 17 (10 by maintainers)

Most upvoted comments

I have reinstalled to use python 3.7.3, and everything works just fine, it seems a compatibility issue between python 3.7.4 and pytest.

Closing this for now given that this was fixed upstream. 👍