Python 在函数中执行数据库查询时,列表索引超出范围

Python 在函数中执行数据库查询时,列表索引超出范围,python,python-2.7,testing,hypothesis-test,python-hypothesis,Python,Python 2.7,Testing,Hypothesis Test,Python Hypothesis,我正在使用Python假设为数据库编写随机测试。 在1-2次循环之后,将给定的值插入到表中,我得到了超出范围的列表索引和@seed以进行复制。 没有什么东西会失败,我还没有断言什么。 我如何调试这个 谢谢 run_statement("create table t (x int)") @given(st.integers(1,10), st.integers(1,10)) def insert_select(x): assu

我正在使用Python假设为数据库编写随机测试。 在1-2次循环之后,将给定的值插入到表中,我得到了超出范围的列表索引和@seed以进行复制。 没有什么东西会失败,我还没有断言什么。 我如何调试这个

谢谢

        run_statement("create table t (x int)")
        @given(st.integers(1,10), st.integers(1,10))
        def insert_select(x):
            assume(x)
            run_statement("insert into t values ({})".format(x))
            select_results = run_statement_with_results("select * from t")
            print select_results

        insert_select()

结果:

You can add @seed(257907719204305935240373390472712621009) to this test to reproduce this failure.
timeout
error: list index out of range

不幸的是,这一测试从根本上被打破了:

  • 您正在测试用例的执行之间共享数据库状态,这不能发生,否则您的测试将无法生成
  • 您为给定的
    @提供了两个参数,但测试函数只接受一个参数
  • 假设(x)
    调用是没有意义的,因为
    x
    永远不会是错误的
一旦这些问题得到解决,问题很可能会消失