当我运行以下简单测试时
安装Python 3.6.0 :: Anaconda custom (64-bit)
后,它就会通过。
安装Python 3.6.2 :: Continuum Analytics, Inc.
后,它会无声地失败,详情如下。我可以看到它收集测试,但没有得到它运行它们的任何迹象,它从不宣布传递(或任何结果)。
"""Originally these imports were from tests for qutebrowser.utils.debug."""
import logging
import re
import time
import textwrap
import pytest
from PyQt5.QtCore import pyqtSignal, Qt, QEvent, QObject
from PyQt5.QtWidgets import QStyle, QFrame
from qutebrowser.utils import debug
def test_always_true(qapp, caplog):
assert True == True
这是根据我试图从qutebrowser项目运行的测试改编而来,特别是tests\unit\utils\test_debug.py
。我将尝试将我自己的代码进一步削减到最小的情况。
C:\(path to qutebrowser)\qutebrowser>\python36\python.exe -bb -m pytest pjr\test_pjr.py
============================= test session starts =============================
platform win32 -- Python 3.6.2, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
benchmark: 3.1.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
PyQt5 5.6 -- Qt runtime 5.6.2 -- Qt compiled 5.6.2
rootdir: C:\(path to qutebrowser)\qutebrowser, inifile: pytest.ini
plugins: hypothesis-3.14.0, bdd-2.18.2, benchmark-3.1.1, catchlog-1.2.2, cov-2.5.1, faulthandler-1.3.1, instafail-0.3.0, mock-1.6.2, qt-2.1.2, repeat-0.4.1, rerunfailures-2.2, travis-fold-1.2.0, xvfb-1.0.0
collected 1 item s
pjr\test_pjr.py
在@TheCompiler的帮助下,我发现from PyQt5 import QtWidgets; app= QtWidgets.QApplication([])
在第二个(损坏的)案例中使用的实例中生成以下消息:
This application failed to start because it could not find or load the Qt platform plugin "windows"
in "".
Reinstalling the application may fix this problem.
C:(path to qb)\qutebrowser>c:\python36\python.exe -bb -m pytest pjr\test_pjr.py
============================= test session starts =============================
platform win32 -- Python 3.6.2, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
benchmark: 3.1.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
PyQt5 5.6 -- Qt runtime 5.6.2 -- Qt compiled 5.6.2
rootdir: C:(path to qb)\qutebrowser, inifile: pytest.ini
plugins: hypothesis-3.14.0, bdd-2.18.2, benchmark-3.1.1, catchlog-1.2.2, cov-2.5.1, faulthandler-1.3.1, instafail-0.3.0, mock-1.6.2, qt-2.1.2, repeat-0.4.1, rerunfailures-2.2, travis-fold-1.2.0, xvfb-1.0.0
collecting 0 items
>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>
> c:(path to qb)\qutebrowser\pjr\test_pjr.py(36)<module>()
-> def test_always_true(qapp, caplog):
(Pdb) w
c:\python36\lib\runpy.py(193)_run_module_as_main()
-> "__main__", mod_spec)
c:\python36\lib\runpy.py(85)_run_code()
-> exec(code, run_globals)
c:\python36\lib\site-packages\pytest.py(73)<module>()
-> raise SystemExit(pytest.main())
c:\python36\lib\site-packages\_pytest\config.py(58)main()
-> return config.hook.pytest_cmdline_main(config=config)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(745)__call__()
-> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(339)_hookexec()
-> return self._inner_hookexec(hook, methods, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(334)<lambda>()
-> _MultiCall(methods, kwargs, hook.spec_opts).execute()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(614)execute()
-> res = hook_impl.function(*args)
c:\python36\lib\site-packages\_pytest\main.py(134)pytest_cmdline_main()
-> return wrap_session(config, _main)
c:\python36\lib\site-packages\_pytest\main.py(105)wrap_session()
-> session.exitstatus = doit(config, session) or 0
c:\python36\lib\site-packages\_pytest\main.py(140)_main()
-> config.hook.pytest_collection(session=session)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(745)__call__()
-> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(339)_hookexec()
-> return self._inner_hookexec(hook, methods, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(334)<lambda>()
-> _MultiCall(methods, kwargs, hook.spec_opts).execute()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(614)execute()
-> res = hook_impl.function(*args)
c:\python36\lib\site-packages\_pytest\main.py(150)pytest_collection()
-> return session.perform_collect()
c:\python36\lib\site-packages\_pytest\main.py(603)perform_collect()
-> items = self._perform_collect(args, genitems)
c:\python36\lib\site-packages\_pytest\main.py(640)_perform_collect()
-> self.items.extend(self.genitems(node))
c:\python36\lib\site-packages\_pytest\main.py(779)genitems()
-> rep = collect_one_node(node)
c:\python36\lib\site-packages\_pytest\runner.py(457)collect_one_node()
-> rep = ihook.pytest_make_collect_report(collector=collector)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(745)__call__()
-> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(339)_hookexec()
-> return self._inner_hookexec(hook, methods, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(334)<lambda>()
-> _MultiCall(methods, kwargs, hook.spec_opts).execute()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(613)execute()
-> return _wrapped_call(hook_impl.function(*args), self.execute)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(248)_wrapped_call()
-> call_outcome = _CallOutcome(func)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(265)__init__()
-> self.result = func()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(614)execute()
-> res = hook_impl.function(*args)
c:\python36\lib\site-packages\_pytest\runner.py(329)pytest_make_collect_report()
-> 'collect')
c:\python36\lib\site-packages\_pytest\runner.py(157)__init__()
-> self.result = func()
c:\python36\lib\site-packages\_pytest\runner.py(328)<lambda>()
-> lambda: list(collector.collect()),
c:\python36\lib\site-packages\_pytest\python.py(401)collect()
-> self.session._fixturemanager.parsefactories(self)
c:\python36\lib\site-packages\_pytest\fixtures.py(1057)parsefactories()
-> holderobj = node_or_obj.obj
c:\python36\lib\site-packages\_pytest\python.py(204)fget()
-> self._obj = obj = self._getobj()
c:\python36\lib\site-packages\_pytest\python.py(398)_getobj()
-> return self._importtestmodule()
c:\python36\lib\site-packages\_pytest\python.py(408)_importtestmodule()
-> mod = self.fspath.pyimport(ensuresyspath=importmode)
c:\python36\lib\site-packages\py\_path\local.py(662)pyimport()
-> __import__(modname)
<frozen importlib._bootstrap>(961)_find_and_load()
<frozen importlib._bootstrap>(950)_find_and_load_unlocked()
<frozen importlib._bootstrap>(646)_load_unlocked()
<frozen importlib._bootstrap>(616)_load_backward_compatible()
c:\python36\lib\site-packages\_pytest\assertion\rewrite.py(211)load_module()
-> py.builtin.exec_(co, mod.__dict__)
> c:(path to qb)\qutebrowser\pjr\test_pjr.py(36)<module>()
-> def test_always_true(qapp, caplog):
(Pdb) w
c:\python36\lib\runpy.py(193)_run_module_as_main()
-> "__main__", mod_spec)
c:\python36\lib\runpy.py(85)_run_code()
-> exec(code, run_globals)
c:\python36\lib\site-packages\pytest.py(73)<module>()
-> raise SystemExit(pytest.main())
c:\python36\lib\site-packages\_pytest\config.py(58)main()
-> return config.hook.pytest_cmdline_main(config=config)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(745)__call__()
-> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(339)_hookexec()
-> return self._inner_hookexec(hook, methods, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(334)<lambda>()
-> _MultiCall(methods, kwargs, hook.spec_opts).execute()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(614)execute()
-> res = hook_impl.function(*args)
c:\python36\lib\site-packages\_pytest\main.py(134)pytest_cmdline_main()
-> return wrap_session(config, _main)
c:\python36\lib\site-packages\_pytest\main.py(105)wrap_session()
-> session.exitstatus = doit(config, session) or 0
c:\python36\lib\site-packages\_pytest\main.py(140)_main()
-> config.hook.pytest_collection(session=session)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(745)__call__()
-> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(339)_hookexec()
-> return self._inner_hookexec(hook, methods, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(334)<lambda>()
-> _MultiCall(methods, kwargs, hook.spec_opts).execute()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(614)execute()
-> res = hook_impl.function(*args)
c:\python36\lib\site-packages\_pytest\main.py(150)pytest_collection()
-> return session.perform_collect()
c:\python36\lib\site-packages\_pytest\main.py(603)perform_collect()
-> items = self._perform_collect(args, genitems)
c:\python36\lib\site-packages\_pytest\main.py(640)_perform_collect()
-> self.items.extend(self.genitems(node))
c:\python36\lib\site-packages\_pytest\main.py(779)genitems()
-> rep = collect_one_node(node)
c:\python36\lib\site-packages\_pytest\runner.py(457)collect_one_node()
-> rep = ihook.pytest_make_collect_report(collector=collector)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(745)__call__()
-> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(339)_hookexec()
-> return self._inner_hookexec(hook, methods, kwargs)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(334)<lambda>()
-> _MultiCall(methods, kwargs, hook.spec_opts).execute()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(613)execute()
-> return _wrapped_call(hook_impl.function(*args), self.execute)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(248)_wrapped_call()
-> call_outcome = _CallOutcome(func)
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(265)__init__()
-> self.result = func()
c:\python36\lib\site-packages\_pytest\vendored_packages\pluggy.py(614)execute()
-> res = hook_impl.function(*args)
c:\python36\lib\site-packages\_pytest\runner.py(329)pytest_make_collect_report()
-> 'collect')
c:\python36\lib\site-packages\_pytest\runner.py(157)__init__()
-> self.result = func()
c:\python36\lib\site-packages\_pytest\runner.py(328)<lambda>()
-> lambda: list(collector.collect()),
c:\python36\lib\site-packages\_pytest\python.py(401)collect()
-> self.session._fixturemanager.parsefactories(self)
c:\python36\lib\site-packages\_pytest\fixtures.py(1057)parsefactories()
-> holderobj = node_or_obj.obj
c:\python36\lib\site-packages\_pytest\python.py(204)fget()
-> self._obj = obj = self._getobj()
c:\python36\lib\site-packages\_pytest\python.py(398)_getobj()
-> return self._importtestmodule()
c:\python36\lib\site-packages\_pytest\python.py(408)_importtestmodule()
-> mod = self.fspath.pyimport(ensuresyspath=importmode)
c:\python36\lib\site-packages\py\_path\local.py(662)pyimport()
-> __import__(modname)
<frozen importlib._bootstrap>(961)_find_and_load()
<frozen importlib._bootstrap>(950)_find_and_load_unlocked()
<frozen importlib._bootstrap>(646)_load_unlocked()
<frozen importlib._bootstrap>(616)_load_backward_compatible()
c:\python36\lib\site-packages\_pytest\assertion\rewrite.py(211)load_module()
-> py.builtin.exec_(co, mod.__dict__)
> c:(path to qb)\qutebrowser\pjr\test_pjr.py(36)<module>()
-> def test_always_true(qapp, caplog):
(Pdb) c
collected 1 item
pjr\test_pjr.py