@@ -0,0 +1,1758 @@
+# -*- coding: utf-8 -*-%0A%0A# vim: tabstop=4 shiftwidth=4 softtabstop=4%0A%0A#    Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.%0A#%0A#    Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A#    not use this file except in compliance with the License. You may obtain%0A#    a copy of the License at%0A#%0A#         http://www.apache.org/licenses/LICENSE-2.0%0A#%0A#    Unless required by applicable law or agreed to in writing, software%0A#    distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A#    License for the specific language governing permissions and limitations%0A#    under the License.%0A%0Aimport functools%0Aimport unittest%0A%0Afrom taskflow import utils%0A%0A%0Aclass UtilTest(unittest.TestCase):%0A    def test_rollback_accum(self):%0A        context = %7B%7D%0A%0A        def caller(token, e):%0A            context%5Btoken%5D = True%0A%0A        accum = utils.RollbackAccumulator()%0A%0A        def blowup():%0A            for i in range(0, 10):%0A                accum.add(functools.partial(caller, i))%0A            self.assertEquals(0, len(context))%0A            raise Exception%0A%0A        # Test manual triggering%0A        self.assertEquals(0, len(accum))%0A        self.assertRaises(Exception, blowup)%0A        self.assertEquals(10, len(accum))%0A        self.assertEquals(0, len(context))%0A        accum.rollback(Exception())%0A        self.assertEquals(10, len(context))%0A%0A        # Test context manager triggering%0A        context = %7B%7D%0A        accum.reset()%0A        self.assertEquals(0, len(accum))%0A        try:%0A            with accum:%0A                blowup()%0A        except Exception:%0A            pass%0A        self.assertEquals(10, len(accum))%0A        self.assertEquals(10, len(context))%0A

Add a basic rollback accumlator test.