我在PyCharm中创建了一个鼻子测试配置.我在我工作的virtualenv中安装了NoseGAE.从终端运行测试./env/bin/nosetests --with-gae src/tests工作得很好.然而,PyCharm测试配置产生了
/Users/bistenes/Code/myproject/env/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/noserunner.py src/tests/
Testing started at 6:31 PM ...
/Users/bistenes/Code/myproject/env/lib/python2.7/site-packages/nose/plugins/manager.py:395: RuntimeWarning: Unable to load plugin nosegae = nosegae:NoseGAE: nose>=0.10.1
RuntimeWarning)
Run Code Online (Sandbox Code Playgroud)
Config设置为Nosetests,"All in folder" src/tests.无论是否--with-gae作为参数传递,都会发生错误.
随后的失败表明NoseGAE未加载:
AssertionError: No api proxy found for service "datastore_v3"
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建测试以验证我的实体是否正在保存在数据库中.当我在post函数中放置断点时,我可以看到保存记录后客户计数发生了变化.我阅读了https://cloud.google.com/appengine/docs/python/tools/localunittesting#Python_Writing_High_Replication_Datastore_tests
根据我的理解,由于最终的一致性,测试失败了,解决这个问题的方法是改变PseudoRandomHRConsistencyPolicy设置.
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
Run Code Online (Sandbox Code Playgroud)
当我再次运行测试时,我得到了同样的错误.
创建这些测试我做错了什么?
> /Users/Bryan/work/GoogleAppEngine/dermalfillersecrets/main.py(137)post()
-> customer.put()
(Pdb) l
134 query = Customer.query()
135 orig_customer_count = query.count()
136 import pdb; pdb.set_trace()
137 -> customer.put()
138 import pdb; pdb.set_trace()
139 query_params = {'leadbook_name': leadbook_name}
140 self.redirect('/?' + urllib.urlencode(query_params))
141
142 config = {}
(Pdb) orig_customer_count
5
(Pdb) c
> /Users/Bryan/work/GoogleAppEngine/dermalfillersecrets/main.py(139)post()
-> query_params = {'leadbook_name': leadbook_name}
(Pdb) l
134 query = Customer.query()
135 orig_customer_count = query.count()
136 import pdb; pdb.set_trace()
137 customer.put()
138 import pdb; pdb.set_trace()
139 …Run Code Online (Sandbox Code Playgroud) python google-app-engine selenium-webdriver google-cloud-datastore nose-gae