def setUp(self):
# First, create an instance of the Testbed class.
self.testbed = testbed.Testbed()
# Then activate the testbed, which prepares the service stubs for use.
self.testbed.activate()
# Create a consistency policy that will simulate the High Replication
# consistency model.
self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(
probability=0)
# Initialize the datastore stub with this policy.
self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)
# Initialize memcache stub too, since ndb also uses memcache
self.testbed.init_memcache_stub()
# Clear in-context cache before each test.
ndb.get_context().clear_cache()
评论列表
文章目录