我不能讓這種錯誤的任何意義:處理程序測試失敗:WebTest的導入錯誤
======================================================================
ERROR: test_webtest (unittest2.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_webtest
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/unittest2/loader.py", line 260, in _find_tests
module = self._get_module_from_name(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/unittest2/loader.py", line 238, in _get_module_from_name
__import__(name)
File "/Users/chris/Documents/gae/tasker/test/test_webtest.py", line 4, in <module>
import webtest
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/webtest/__init__.py", line 9, in <module>
from webtest.app import TestApp
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/webtest/app.py", line 65, in <module>
class TestRequest(webob.BaseRequest):
AttributeError: 'module' object has no attribute 'BaseRequest'
的情況是:
- 我試圖建立處理器單元測試我的App Engine應用程序。
- 我正在關注單元測試框架this tutorial,其中包括逐頁底部的 bash腳本。
我從使用此命令的終端運行測試:
./run_tests.py /usr/local/google_appengine test/
我使用this tutorial爲構建我的處理程序測試。但它永遠不會超過進口。所有我需要做的就是這
test/test_webtest.py
生成錯誤:import webtest
我有WebTest的安裝:
$ pip install WebTest Requirement already satisfied (use --upgrade to upgrade): WebTest in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages Requirement already satisfied (use --upgrade to upgrade): six in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from WebTest) Requirement already satisfied (use --upgrade to upgrade): WebOb>=1.2 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from WebTest) Requirement already satisfied (use --upgrade to upgrade): waitress in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from WebTest) Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from WebTest) Requirement already satisfied (use --upgrade to upgrade): distribute in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg (from waitress->WebTest)
我正在我一下子所有測試,包括舊的,與通沒有錯誤。但是將
webtest
導入其中的任何一個會在頂部生成錯誤。爲什麼?
我沒有時間閱讀教程鏈接,但我使用鼻子和鼻子gae進行webtest測試,他們的工作很好。 – 2013-03-17 23:08:37
Kekito:根據下面描述的已知錯誤,我很驚訝你的事情順利進行,我想複製你的魔法。你有意識地解決這個錯誤嗎?你在做與我不同的事嗎? – Chris 2013-03-18 12:40:28
您可能會使用舊版本的GAE SDK。 1.7.5和更早版本有這個問題。目前的最新情況(1.8.8)應該可以解決這個問題。 – 2013-11-28 21:46:54