~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: John Arbash Meinel
  • Date: 2013-05-19 13:38:07 UTC
  • mfrom: (6015.57.4 2.4)
  • mto: (6437.63.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6575.
  • Revision ID: john@arbash-meinel.com-20130519133807-69kfoe85gw2va4y2
Try merging 2.4 into 2.5 and resolving the conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1623
1623
        self.assertRaises(AssertionError,
1624
1624
            self.assertListRaises, _TestException, success_generator)
1625
1625
 
 
1626
    def _run_successful_test(self, test):
 
1627
        result = testtools.TestResult()
 
1628
        test.run(result)
 
1629
        self.assertTrue(result.wasSuccessful())
 
1630
        return result
 
1631
 
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)
1640
1646
 
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)
1644
1649
 
1645
1650
    def test_overrideAttr_with_value(self):
1655
1660
                self.assertEqual('original', self.orig)
1656
1661
                self.assertEqual('modified', obj.test_attr)
1657
1662
 
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)
1661
1665
 
 
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):
 
1670
 
 
1671
            def setUp(self):
 
1672
                tests.TestCase.setUp(self)
 
1673
                self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
 
1674
 
 
1675
            def test_value(self):
 
1676
                self.assertEqual(tests._unitialized_attr, self.orig)
 
1677
                self.assertEqual('modified', obj.test_attr)
 
1678
 
 
1679
        self._run_successful_test(Test('test_value'))
 
1680
        self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1681
 
 
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):
 
1686
 
 
1687
            def setUp(self):
 
1688
                tests.TestCase.setUp(self)
 
1689
                self.orig = self.overrideAttr(obj, 'test_attr')
 
1690
 
 
1691
            def test_value(self):
 
1692
                self.assertEqual(tests._unitialized_attr, self.orig)
 
1693
                self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1694
 
 
1695
        self._run_successful_test(Test('test_value'))
 
1696
        self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1697
 
1662
1698
    def test_recordCalls(self):
1663
1699
        from bzrlib.tests import test_selftest
1664
1700
        calls = self.recordCalls(