'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'

def test_callbacks_work_multiple_times(self):

    call_history = []
    def my_callback(*args, **kwargs):
        call_history.append(args)
    with warnings.catch_warnings(record=True) as w:
        with BatchQuery() as batch:
            batch.add_callback(my_callback)
            batch.execute()
        batch.execute()
    self.assertEqual(len(w), 2)
    self.assertRegexpMatches(str(w[0].message), '^Batch.*multiple.*')
