test_batch_query.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:cqlmapper 作者: reddit 项目源码 文件源码
def test_callbacks_work_multiple_times(self):
        """
        Tests that multiple executions of execute on a batch statement
        logs a warning, and that we don't encounter an attribute error.
        @since 3.1
        @jira_ticket PYTHON-445
        @expected_result warning message is logged

        @test_category object_mapper
        """
        call_history = []

        def my_callback(*args, **kwargs):
            call_history.append(args)

        with warnings.catch_warnings(record=True) as w:
            batch = Batch(self.conn)
            batch.add_callback(my_callback)
            batch.execute_batch()
            batch.execute_batch()
        self.assertEqual(len(w), 1)
        self.assertRegexpMatches(str(w[0].message), r"^Batch.*multiple.*")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号