【问题标题】:GAE Python TestingGAE Python 测试
【发布时间】:2013-05-15 03:54:27
【问题描述】:

首先我对 GAE/Python 很陌生,请多多包涵。情况是这样的

有一个 test_all.py 来测试我包中的所有测试套件。 TestCase 的 setUp 当前的样子;

import test_settings as policy # has consistency variables <- does not work

...

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()
    # Consistency policy nomal operations
    self.policy = None
    if policy.policy_flag == 'STRICT':
        # 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)

这是我最初尝试使用不同的一致性策略设置数据存储以针对它们运行测试。完全失败。

我想要的是从我的根 test_all.py 一次性针对不同的数据存储一致性运行我的测试用例使用上述或其他方法,我该怎么做?如何从测试运行器向 TestCase 传递参数?

【问题讨论】:

  • Re "total fail" -- 你能显示错误,或者你得到的和你期望的相比吗?
  • policy_flat 只是不同模块中的一个变量。我相信 我对它所做的更改不会传播到测试用例中的“导入”中。因此测试仅以默认的起始一致性运行。是否可以从 runner 向 TestCase 类发送参数?

标签: google-app-engine python-2.7


【解决方案1】:

Python, unit test - Pass command line arguments to setUp of unittest.TestCase

上面的线程准确地展示了如何最好地将运行时参数传递给测试用例。具体回答2。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多