pytest 运行文件报错

Posted tqlve

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pytest 运行文件报错相关的知识,希望对你有一定的参考价值。

用pytest 执行时报错:

Traceback (most recent call last):
  File "D:program filesJetBrainsPyCharm Community Edition 2019.2.3helperspycharm\\_jb_pytest_runner.py", line 37, in <module>
    config_result = real_prepare_config(args, plugins_to_load)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestconfig\\__init__.py", line 221, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggyhooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggymanager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggymanager.py", line 86, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggycallers.py", line 203, in _multicall
    gen.send(outcome)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytesthelpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggycallers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggycallers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestconfig\\__init__.py", line 736, in pytest_cmdline_parse
    self.parse(args)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestconfig\\__init__.py", line 943, in parse
    self._preparse(args, addopts=addopts)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestconfig\\__init__.py", line 900, in _preparse
    early_config=self, args=args, parser=self._parser
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggyhooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggymanager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggymanager.py", line 86, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggycallers.py", line 208, in _multicall
    return outcome.get_result()
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggycallers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packagespluggycallers.py", line 182, in _multicall
    next(gen)  # first yield
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestcapture.py", line 53, in pytest_load_initial_conftests
    capman.start_global_capturing()
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestcapture.py", line 111, in start_global_capturing
    self._global_capturing = self._getcapture(self._method)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestcapture.py", line 87, in _getcapture
    return MultiCapture(out=True, err=True, Capture=FDCapture)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestcapture.py", line 455, in __init__
    self.in_ = Capture(0)
  File "F:UsersAdministratorPycharmProjectshogwars10venvlibsite-packages\\_pytestcapture.py", line 554, in __init__
    tmpfile = open(os.devnull, "r")
FileNotFoundError: [Errno 2] No such file or directory: nul

Process finished with exit code 1

Empty suite

技术图片

 

以上是关于pytest 运行文件报错的主要内容,如果未能解决你的问题,请参考以下文章

坑:pytest 运行报错unknown hook 'pytest_namespace' in plugin <module 'allure.pytest_plugin&

运行pytest,提示编码错误

pytest和seldom运行报错

cmd下执行pytest报错找不到文件模块

pytest文档53-命令行实时输出错误信息(pytest-instafail)

解决pytest运行时报错ModuleNotFoundError