[英]Configuring py.test in PyDev (Python 3, Mac)
我有一台Mac,並且已將py.test安裝到Python 3庫(而不是Apple的標准Python 2.7庫)。 這是因為我正在使用Python 3。
但是,當我在PyDev中運行py.test時,會發生以下錯誤。 關於如何解決這個問題的任何解釋? 我已經思考了很長時間了。
collected 1 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/main.py", line 96, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/main.py", line 130, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/main.py", line 139, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/main.py", line 592, in perform_collect
INTERNALERROR> config=self.config, items=items)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/mark.py", line 84, in pytest_collection_modifyitems
INTERNALERROR> if not matchmark(colitem, matchexpr):
INTERNALERROR> File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_pytest/mark.py", line 124, in matchmark
INTERNALERROR> return eval(markexpr, {}, MarkMapping(colitem.keywords))
INTERNALERROR> File "<string>", line 1
INTERNALERROR> axfail=2
INTERNALERROR> ^
INTERNALERROR> SyntaxError: invalid syntax
這是一張圖片:
注意:我已經安裝了LiClipse中捆綁的PyDev。 我已經根據文檔配置了py.test測試運行程序:
--maxfail=2 --tb=native
然后,我根據py.test的文檔運行了一個簡單的py.test測試文件:
def func(x):
return x + 1
def test_answer():
assert func(3) == 5
pytest配置似乎正確。
因此,要檢查一些事情:
您可以使用py.test filename
在命令行中(不在LiClipse中)運行它嗎?
您如何精確地運行測試? (該文件或運行文件夾是Ctrl + F9還是?)
錯誤似乎是在評估pytest中的標記(即pytest.mark.xxx)時出現的,您的項目其他部分是否可能存在無效標記?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.