736
733
except errors.UpgradeRequired:
737
734
raise tests.TestNotApplicable('Format does not support binding')
736
def test_unbind_clears_cached_master_branch(self):
737
"""b.unbind clears any cached value of b.get_master_branch."""
738
master = self.make_branch('master')
739
branch = self.make_branch('branch')
742
except errors.UpgradeRequired:
743
raise tests.TestNotApplicable('Format does not support binding')
744
self.addCleanup(branch.lock_write().unlock)
745
self.assertNotEqual(None, branch.get_master_branch())
747
self.assertEqual(None, branch.get_master_branch())
749
def test_unlocked_does_not_cache_master_branch(self):
750
"""Unlocked branches do not cache the result of get_master_branch."""
751
master = self.make_branch('master')
752
branch1 = self.make_branch('branch')
755
except errors.UpgradeRequired:
756
raise tests.TestNotApplicable('Format does not support binding')
758
branch2 = branch1.bzrdir.open_branch()
759
self.assertNotEqual(None, branch1.get_master_branch())
760
# Unbind the branch via branch2. branch1 isn't locked so will
761
# immediately return the new value for get_master_branch.
763
self.assertEqual(None, branch1.get_master_branch())
765
def test_bind_clears_cached_master_branch(self):
766
"""b.bind clears any cached value of b.get_master_branch."""
767
master1 = self.make_branch('master1')
768
master2 = self.make_branch('master2')
769
branch = self.make_branch('branch')
772
except errors.UpgradeRequired:
773
raise tests.TestNotApplicable('Format does not support binding')
774
self.addCleanup(branch.lock_write().unlock)
775
self.assertNotEqual(None, branch.get_master_branch())
777
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
778
branch.get_master_branch().base))
780
def test_set_bound_location_clears_cached_master_branch(self):
781
"""b.set_bound_location clears any cached value of b.get_master_branch.
783
master1 = self.make_branch('master1')
784
master2 = self.make_branch('master2')
785
branch = self.make_branch('branch')
788
except errors.UpgradeRequired:
789
raise tests.TestNotApplicable('Format does not support binding')
790
self.addCleanup(branch.lock_write().unlock)
791
self.assertNotEqual(None, branch.get_master_branch())
792
branch.set_bound_location(self.get_url('master2'))
793
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
794
branch.get_master_branch().base))
740
797
class TestStrict(per_branch.TestCaseWithBranch):