1623
1623
self.assertRaises(AssertionError,
1624
1624
self.assertListRaises, _TestException, success_generator)
1626
def _run_successful_test(self, test):
1627
result = testtools.TestResult()
1629
self.assertTrue(result.wasSuccessful())
1626
1632
def test_overrideAttr_without_value(self):
1627
1633
self.test_attr = 'original' # Define a test attribute
1628
1634
obj = self # Make 'obj' visible to the embedded test
1638
1644
obj.test_attr = 'modified'
1639
1645
self.assertEqual('modified', obj.test_attr)
1641
test = Test('test_value')
1642
test.run(unittest.TestResult())
1647
self._run_successful_test(Test('test_value'))
1643
1648
self.assertEqual('original', obj.test_attr)
1645
1650
def test_overrideAttr_with_value(self):
1655
1660
self.assertEqual('original', self.orig)
1656
1661
self.assertEqual('modified', obj.test_attr)
1658
test = Test('test_value')
1659
test.run(unittest.TestResult())
1663
self._run_successful_test(Test('test_value'))
1660
1664
self.assertEqual('original', obj.test_attr)
1666
def test_overrideAttr_with_no_existing_value_and_value(self):
1667
# Do not define the test_attribute
1668
obj = self # Make 'obj' visible to the embedded test
1669
class Test(tests.TestCase):
1672
tests.TestCase.setUp(self)
1673
self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
1675
def test_value(self):
1676
self.assertEqual(tests._unitialized_attr, self.orig)
1677
self.assertEqual('modified', obj.test_attr)
1679
self._run_successful_test(Test('test_value'))
1680
self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1682
def test_overrideAttr_with_no_existing_value_and_no_value(self):
1683
# Do not define the test_attribute
1684
obj = self # Make 'obj' visible to the embedded test
1685
class Test(tests.TestCase):
1688
tests.TestCase.setUp(self)
1689
self.orig = self.overrideAttr(obj, 'test_attr')
1691
def test_value(self):
1692
self.assertEqual(tests._unitialized_attr, self.orig)
1693
self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1695
self._run_successful_test(Test('test_value'))
1696
self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1662
1698
def test_recordCalls(self):
1663
1699
from bzrlib.tests import test_selftest
1664
1700
calls = self.recordCalls(