1654
1654
self.assertRaises(AssertionError,
1655
1655
self.assertListRaises, _TestException, success_generator)
1657
def _run_successful_test(self, test):
1658
result = testtools.TestResult()
1660
self.assertTrue(result.wasSuccessful())
1657
1663
def test_overrideAttr_without_value(self):
1658
1664
self.test_attr = 'original' # Define a test attribute
1659
1665
obj = self # Make 'obj' visible to the embedded test
1669
1675
obj.test_attr = 'modified'
1670
1676
self.assertEqual('modified', obj.test_attr)
1672
test = Test('test_value')
1673
test.run(unittest.TestResult())
1678
self._run_successful_test(Test('test_value'))
1674
1679
self.assertEqual('original', obj.test_attr)
1676
1681
def test_overrideAttr_with_value(self):
1686
1691
self.assertEqual('original', self.orig)
1687
1692
self.assertEqual('modified', obj.test_attr)
1689
test = Test('test_value')
1690
test.run(unittest.TestResult())
1694
self._run_successful_test(Test('test_value'))
1691
1695
self.assertEqual('original', obj.test_attr)
1697
def test_overrideAttr_with_no_existing_value_and_value(self):
1698
# Do not define the test_attribute
1699
obj = self # Make 'obj' visible to the embedded test
1700
class Test(tests.TestCase):
1703
tests.TestCase.setUp(self)
1704
self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
1706
def test_value(self):
1707
self.assertEqual(tests._unitialized_attr, self.orig)
1708
self.assertEqual('modified', obj.test_attr)
1710
self._run_successful_test(Test('test_value'))
1711
self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1713
def test_overrideAttr_with_no_existing_value_and_no_value(self):
1714
# Do not define the test_attribute
1715
obj = self # Make 'obj' visible to the embedded test
1716
class Test(tests.TestCase):
1719
tests.TestCase.setUp(self)
1720
self.orig = self.overrideAttr(obj, 'test_attr')
1722
def test_value(self):
1723
self.assertEqual(tests._unitialized_attr, self.orig)
1724
self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1726
self._run_successful_test(Test('test_value'))
1727
self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1693
1729
def test_recordCalls(self):
1694
1730
from bzrlib.tests import test_selftest
1695
1731
calls = self.recordCalls(