我无法理解这个错误:
======================================================================
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 应用设置处理程序单元测试。
- 我正在关注本教程以获取单元测试框架,包括页面底部的 bash 脚本,逐字逐句。
我正在使用以下命令从终端运行测试:
./run_tests.py /usr/local/google_appengine test/
我正在使用本教程来构建我的处理程序测试。但它永远不会超过进口。我所要做的就是
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
其中任何一个都会在顶部生成错误。为什么?