def test_begin_close(self):
    canary = mock.Mock()
    with testing.db.connect() as connection:
        event.listen(connection, 'rollback', canary)
        trans = connection.begin()
        assert (connection.connection._reset_agent is trans)
    assert (not trans.is_active)
    eq_(canary.mock_calls, [mock.call(connection)])
def test_begin_close(self):
    canary = mock.Mock()
    with testing.db.connect() as connection:
        event.listen(connection, 'rollback', canary)
        trans = connection.begin()
        assert (connection.connection._reset_agent is trans)
    assert (not trans.is_active)
    eq_(canary.mock_calls, [mock.call(connection)])