奇怪的东西。第一次,当我从 eclipse 运行你的代码时,我遇到了与以前相同的错误,但在重新启动 eclipse 后,我再次运行它并且你的代码工作正常:
Running in: C:\MojeApps\Python365\python.exe
PyTest found in: C:\MojeApps\Python365\lib\site-packages\pytest\__init__.py
============================= test session starts =============================
platform win32 -- Python 3.6.5, pytest-6.0.0, py-1.9.0, pluggy-0.13.1
rootdir: C:\Development\eclipse_workspace\PySandbox\pytest_so_help
collected 2 items
main.py .F [100%]
================================== FAILURES ===================================
________________________________ test_inc_fail ________________________________
def test_inc_fail():
> assert inc(5) == 5
E assert 6 == 5
E + where 6 = inc(5)
main.py:10: AssertionError
=========================== short test summary info ===========================
FAILED main.py::test_inc_fail - assert 6 == 5
========================= 1 failed, 1 passed in 0.03s =========================
通过 Eclipse 运行“我的测试”给了我新的错误 :)
============================= test session starts =============================
platform win32 -- Python 3.6.5, pytest-6.0.0, py-1.9.0, pluggy-0.13.1
rootdir: C:\Development\eclipse_workspace\MyPyTests\src
collected 2 items
tests\test_sample.py .F
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\_pytest\main.py", line 240, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\_pytest\main.py", line 296, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\_pytest\main.py", line 321, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\_pytest\runner.py", line 100, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\_pytest\runner.py", line 117, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\_pytest\runner.py", line 211, in call_and_report
INTERNALERROR> hook.pytest_runtest_logreport(report=report)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\MojeApps\Python365\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\MojeApps\eclipse\plugins\org.python.pydev.core_7.6.0.202006041357\pysrc\_pydev_runfiles\pydev_runfiles_pytest2.py", line 265, in pytest_runtest_logreport
INTERNALERROR> exc = _get_error_contents_from_report(report)
INTERNALERROR> File "C:\MojeApps\eclipse\plugins\org.python.pydev.core_7.6.0.202006041357\pysrc\_pydev_runfiles\pydev_runfiles_pytest2.py", line 167, in _get_error_contents_from_report
INTERNALERROR> tw = TerminalWriter(stringio=True)
INTERNALERROR> TypeError: __init__() got an unexpected keyword argument 'stringio'
========================= 1 failed, 1 passed in 0.05s =========================
我开始认为 pydev 插件坏了...
编辑:
奇怪的事情。在我启动操作系统的那晚之后,检查它是否仍然出现 - 它突然开始工作而没有问题 - 我不知道......