~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Patch Queue Manager
  • Date: 2013-05-23 10:35:23 UTC
  • mfrom: (6574.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20130523103523-2wt6jmauja1n1vdt
(jameinel) Merge bzr/2.5 into trunk. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1654
1654
        self.assertRaises(AssertionError,
1655
1655
            self.assertListRaises, _TestException, success_generator)
1656
1656
 
 
1657
    def _run_successful_test(self, test):
 
1658
        result = testtools.TestResult()
 
1659
        test.run(result)
 
1660
        self.assertTrue(result.wasSuccessful())
 
1661
        return result
 
1662
 
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)
1671
1677
 
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)
1675
1680
 
1676
1681
    def test_overrideAttr_with_value(self):
1686
1691
                self.assertEqual('original', self.orig)
1687
1692
                self.assertEqual('modified', obj.test_attr)
1688
1693
 
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)
1692
1696
 
 
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):
 
1701
 
 
1702
            def setUp(self):
 
1703
                tests.TestCase.setUp(self)
 
1704
                self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
 
1705
 
 
1706
            def test_value(self):
 
1707
                self.assertEqual(tests._unitialized_attr, self.orig)
 
1708
                self.assertEqual('modified', obj.test_attr)
 
1709
 
 
1710
        self._run_successful_test(Test('test_value'))
 
1711
        self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1712
 
 
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):
 
1717
 
 
1718
            def setUp(self):
 
1719
                tests.TestCase.setUp(self)
 
1720
                self.orig = self.overrideAttr(obj, 'test_attr')
 
1721
 
 
1722
            def test_value(self):
 
1723
                self.assertEqual(tests._unitialized_attr, self.orig)
 
1724
                self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1725
 
 
1726
        self._run_successful_test(Test('test_value'))
 
1727
        self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1728
 
1693
1729
    def test_recordCalls(self):
1694
1730
        from bzrlib.tests import test_selftest
1695
1731
        calls = self.recordCalls(