Merge lp:~jameinel/bzr/2.5-merges-2.4 into lp:bzr/2.5

Proposed by John A Meinel
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 6512
Proposed branch: lp:~jameinel/bzr/2.5-merges-2.4
Merge into: lp:bzr/2.5
Diff against target: 92 lines (+48/-6)
2 files modified
bzrlib/tests/__init__.py (+8/-2)
bzrlib/tests/test_selftest.py (+40/-4)
To merge this branch: bzr merge lp:~jameinel/bzr/2.5-merges-2.4
Reviewer Review Type Date Requested Status
Richard Wilbur Approve
Review via email: mp+164620@code.launchpad.net

Commit message

Merge 2.4 into 2.5, and resolve a few conflicts wrt extract_format_string().

Description of the change

This is a merge of 2.4 into 2.5.

I had been working with an out-of-date 2.5 branch. This new diff is just the overrideAttr fixes.

To post a comment you must log in.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Looks like these changes only touch the test suite. Thanks for taking the time to update the fixes so they can go into 2.5!
+1

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2012-04-30 09:50:33 +0000
+++ bzrlib/tests/__init__.py 2013-05-19 14:34:34 +0000
@@ -1782,9 +1782,15 @@
17821782
1783 :returns: The actual attr value.1783 :returns: The actual attr value.
1784 """1784 """
1785 value = getattr(obj, attr_name)
1786 # The actual value is captured by the call below1785 # The actual value is captured by the call below
1787 self.addCleanup(setattr, obj, attr_name, value)1786 value = getattr(obj, attr_name, _unitialized_attr)
1787 if value is _unitialized_attr:
1788 # When the test completes, the attribute should not exist, but if
1789 # we aren't setting a value, we don't need to do anything.
1790 if new is not _unitialized_attr:
1791 self.addCleanup(delattr, obj, attr_name)
1792 else:
1793 self.addCleanup(setattr, obj, attr_name, value)
1788 if new is not _unitialized_attr:1794 if new is not _unitialized_attr:
1789 setattr(obj, attr_name, new)1795 setattr(obj, attr_name, new)
1790 return value1796 return value
17911797
=== modified file 'bzrlib/tests/test_selftest.py'
--- bzrlib/tests/test_selftest.py 2012-09-07 10:33:40 +0000
+++ bzrlib/tests/test_selftest.py 2013-05-19 14:34:34 +0000
@@ -1653,6 +1653,12 @@
1653 self.assertRaises(AssertionError,1653 self.assertRaises(AssertionError,
1654 self.assertListRaises, _TestException, success_generator)1654 self.assertListRaises, _TestException, success_generator)
16551655
1656 def _run_successful_test(self, test):
1657 result = testtools.TestResult()
1658 test.run(result)
1659 self.assertTrue(result.wasSuccessful())
1660 return result
1661
1656 def test_overrideAttr_without_value(self):1662 def test_overrideAttr_without_value(self):
1657 self.test_attr = 'original' # Define a test attribute1663 self.test_attr = 'original' # Define a test attribute
1658 obj = self # Make 'obj' visible to the embedded test1664 obj = self # Make 'obj' visible to the embedded test
@@ -1668,8 +1674,7 @@
1668 obj.test_attr = 'modified'1674 obj.test_attr = 'modified'
1669 self.assertEqual('modified', obj.test_attr)1675 self.assertEqual('modified', obj.test_attr)
16701676
1671 test = Test('test_value')1677 self._run_successful_test(Test('test_value'))
1672 test.run(unittest.TestResult())
1673 self.assertEqual('original', obj.test_attr)1678 self.assertEqual('original', obj.test_attr)
16741679
1675 def test_overrideAttr_with_value(self):1680 def test_overrideAttr_with_value(self):
@@ -1685,10 +1690,41 @@
1685 self.assertEqual('original', self.orig)1690 self.assertEqual('original', self.orig)
1686 self.assertEqual('modified', obj.test_attr)1691 self.assertEqual('modified', obj.test_attr)
16871692
1688 test = Test('test_value')1693 self._run_successful_test(Test('test_value'))
1689 test.run(unittest.TestResult())
1690 self.assertEqual('original', obj.test_attr)1694 self.assertEqual('original', obj.test_attr)
16911695
1696 def test_overrideAttr_with_no_existing_value_and_value(self):
1697 # Do not define the test_attribute
1698 obj = self # Make 'obj' visible to the embedded test
1699 class Test(tests.TestCase):
1700
1701 def setUp(self):
1702 tests.TestCase.setUp(self)
1703 self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
1704
1705 def test_value(self):
1706 self.assertEqual(tests._unitialized_attr, self.orig)
1707 self.assertEqual('modified', obj.test_attr)
1708
1709 self._run_successful_test(Test('test_value'))
1710 self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1711
1712 def test_overrideAttr_with_no_existing_value_and_no_value(self):
1713 # Do not define the test_attribute
1714 obj = self # Make 'obj' visible to the embedded test
1715 class Test(tests.TestCase):
1716
1717 def setUp(self):
1718 tests.TestCase.setUp(self)
1719 self.orig = self.overrideAttr(obj, 'test_attr')
1720
1721 def test_value(self):
1722 self.assertEqual(tests._unitialized_attr, self.orig)
1723 self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1724
1725 self._run_successful_test(Test('test_value'))
1726 self.assertRaises(AttributeError, getattr, obj, 'test_attr')
1727
1692 def test_recordCalls(self):1728 def test_recordCalls(self):
1693 from bzrlib.tests import test_selftest1729 from bzrlib.tests import test_selftest
1694 calls = self.recordCalls(1730 calls = self.recordCalls(

Subscribers

People subscribed via source and target branches