def test_change_attr(self):
        class Foo(object):
            def __init__(self):
                self.foo = 1
        obj = Foo()
        self.assertEqual(obj.foo, 1)
        with self.changeAttr(obj, 'foo', 2):
            self.assertEqual(obj.foo, 2)
        self.assertEqual(obj.foo, 1)
        # Check that the attribute is restored when an exception happens.
        try:
            with self.changeAttr(obj, 'foo', 2):
                raise ValueError()
        except __HOLE__:
            pass
        self.assertEqual(obj.foo, 1)
dataset/ETHPy150Open cjerdonek/open-rcv/openrcv/test/utiltest/test_helpers.py/UnitCaseTest.test_change_attr