我正在为在App Engine上运行的基于Flask的应用程序编写单元测试。
根据documentation,我已经包含以下几行
import sys
sys.path.insert(1, '/Users/vinay/tools/google_appengine')
sys.path.insert(1, '/Users/vinay/tools/google_appengine/lib/yaml/lib')
sys.path.insert(1, '/Users/vinay/App-Engine/zion-alpha/lib')
这是完整的测试文件。
import sys
sys.path.insert(1, '/Users/vinay/tools/google_appengine')
sys.path.insert(1, '/Users/vinay/tools/google_appengine/lib/yaml/lib')
sys.path.insert(1, '/Users/vinay/App-Engine/zion-alpha/lib')
from pprint import pprint
pprint(sys.path)
from google.appengine.ext import ndb
from webtest import TestApp
from app import create_app
from Tests.base_test import TestBase
app = TestApp(create_app())
class AppTest(TestBase):
def test_index(self):
response = app.get('/')
self.assertEqual(response.content_type, 'text/plain')
self.assertEqual('Hello World', response.body)
当我运行此脚本时,我收到以下错误。
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py /Users/vinay/App-Engine/zion-alpha/Tests/handler_tests.py true
Testing started at 10:31 AM ...
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 121, in <module>
modules = [loadSource(a[0])]
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 43, in loadSource
module = imp.load_source(moduleName, fileName)
File "/Users/vinay/App-Engine/zion-alpha/Tests/handler_tests.py", line 10, in <module>
from google.appengine.ext import ndb
ImportError: No module named appengine.ext
['/Users/vinay/App-Engine/zion-alpha/Tests',
'/Users/vinay/App-Engine/zion-alpha/lib',
'/Users/vinay/tools/google_appengine/lib/yaml/lib',
'/Users/vinay/tools/google_appengine',
'/Library/Python/2.7/site-packages/python_gflags-2.0-py2.7.egg',
'/Library/Python/2.7/site-packages/xunitparser-1.3.3-py2.7.egg',
'/Library/Python/2.7/site-packages/setuptools-20.6.7-py2.7.egg',
'/Library/Python/2.7/site-packages',
'/Users/vinay/tools/google_appengine/lib/apiclient',
'/Users/vinay/tools/google_appengine/lib/markupsafe-0.15',
'/Users/vinay/tools/google_appengine/lib/concurrent',
'/Users/vinay/tools/google_appengine/lib/distutils',
'/Users/vinay/tools/google_appengine/lib/httplib2',
'/Users/vinay/tools/google_appengine/lib/fancy_urllib',
'/Users/vinay/tools/google_appengine/lib/oauth2client',
'/Users/vinay/tools/google_appengine/lib/cacerts',
'/Users/vinay/tools/google_appengine/lib/requests',
'/Users/vinay/tools/google_appengine/lib/cherrypy',
'/Users/vinay/tools/google_appengine/lib/ipaddr',
'/Users/vinay/tools/google_appengine/lib/prettytable',
'/Users/vinay/tools/google_appengine/lib/grizzled',
'/Users/vinay/App-Engine/zion-alpha/lib',
'/Users/vinay/tools/google_appengine/lib/rsa',
'/Users/vinay/tools/google_appengine/lib/oauth2',
'/Users/vinay/tools/google_appengine/lib/pyasn1',
'/Users/vinay/tools/google_appengine/lib/sqlcmd',
'/Users/vinay/tools/google_appengine/lib/webob-1.2.3',
'/Users/vinay/tools/google_appengine/lib/antlr3',
'/Users/vinay/tools/google_appengine/lib/jinja2-2.6',
'/Users/vinay/tools/google_appengine/lib/endpoints-1.0',
'/Users/vinay/tools/google_appengine/lib/graphy',
'/Users/vinay/tools/google_appengine/lib/websocket',
'/Users/vinay/tools/google_appengine/lib/google-api-python-client',
'/Users/vinay/tools/google_appengine/lib/setuptools-0.6c11',
'/Users/vinay/tools/google_appengine/lib/yaml-3.10',
'/Users/vinay/tools/google_appengine/lib/docker',
'/Users/vinay/tools/google_appengine',
'/Users/vinay/tools/google_appengine/lib/mox',
'/Users/vinay/tools/google_appengine/lib/django-1.9',
'/Users/vinay/tools/google_appengine/lib/six',
'/Users/vinay/tools/google_appengine/lib/webapp2-2.5.2',
'/Users/vinay/tools/google_appengine/lib/deprecated_enum',
'/Users/vinay/tools/google_appengine/lib/portpicker',
'/Users/vinay/tools/google_appengine/lib/argparse',
'/Users/vinay/tools/google_appengine/lib/uritemplate',
'/Users/vinay/tools/google_appengine/lib/protorpc-1.0',
'/Users/vinay/tools/google_appengine/lib/PyAMF-0.7.2',
'/Users/vinay/tools/google_appengine/lib/simplejson',
'/Users/vinay/App-Engine/zion-alpha',
'/Users/vinay/tools/google_appengine/lib/PyAMF-0.6.1',
'/Users/vinay/tools/google_appengine/lib/pyasn1_modules',
'/Users/vinay/tools/google_appengine/lib/python-gflags',
'/Applications/PyCharm.app/Contents/helpers/pycharm',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/var/root/Library/Python/2.7/lib/python/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
Process finished with exit code 1
包裹位于正确的位置。
bash-3.2$ ls
google_appengine google_appengine_1.9.40.zip
bash-3.2$ pwd
/Users/vinay/tools
bash-3.2$
答案 0 :(得分:0)
看起来您认为自己没有$query = "SELECT date FROM arrival order by date" ;
$result = mysqli_query($con,$query)or die ("Error". mysqli_error($con)) ;
echo "<select name='per1' id='per1'>";
while ($row = mysqli_fetch_array ($result)){?>
<option value='<?php echo $row['date'];?>' selected='selected'><?php echo $row['date'];?></option>
<?php } ?>
</select>
个包裹。如果尝试向sys路径添加不存在的路径,则不会看到错误。在第5行和第7行之间添加此内容以检查您的路径:
google_appengine
检查路径中的多个appengine包。导航到每个,以确保它真的存在。