736
736
except errors.UpgradeRequired:
737
737
raise tests.TestNotApplicable('Format does not support binding')
739
def test_unbind_clears_cached_master_branch(self):
740
"""b.unbind clears any cached value of b.get_master_branch."""
741
master = self.make_branch('master')
742
branch = self.make_branch('branch')
745
except errors.UpgradeRequired:
746
raise tests.TestNotApplicable('Format does not support binding')
747
self.addCleanup(branch.lock_write().unlock)
748
self.assertNotEqual(None, branch.get_master_branch())
750
self.assertEqual(None, branch.get_master_branch())
752
def test_unlocked_does_not_cache_master_branch(self):
753
"""Unlocked branches do not cache the result of get_master_branch."""
754
master = self.make_branch('master')
755
branch1 = self.make_branch('branch')
758
except errors.UpgradeRequired:
759
raise tests.TestNotApplicable('Format does not support binding')
761
branch2 = branch1.bzrdir.open_branch()
762
self.assertNotEqual(None, branch1.get_master_branch())
763
# Unbind the branch via branch2. branch1 isn't locked so will
764
# immediately return the new value for get_master_branch.
766
self.assertEqual(None, branch1.get_master_branch())
768
def test_bind_clears_cached_master_branch(self):
769
"""b.bind clears any cached value of b.get_master_branch."""
770
master1 = self.make_branch('master1')
771
master2 = self.make_branch('master2')
772
branch = self.make_branch('branch')
775
except errors.UpgradeRequired:
776
raise tests.TestNotApplicable('Format does not support binding')
777
self.addCleanup(branch.lock_write().unlock)
778
self.assertNotEqual(None, branch.get_master_branch())
780
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
781
branch.get_master_branch().base))
783
def test_set_bound_location_clears_cached_master_branch(self):
784
"""b.set_bound_location clears any cached value of b.get_master_branch.
786
master1 = self.make_branch('master1')
787
master2 = self.make_branch('master2')
788
branch = self.make_branch('branch')
791
except errors.UpgradeRequired:
792
raise tests.TestNotApplicable('Format does not support binding')
793
self.addCleanup(branch.lock_write().unlock)
794
self.assertNotEqual(None, branch.get_master_branch())
795
branch.set_bound_location(self.get_url('master2'))
796
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
797
branch.get_master_branch().base))
740
800
class TestStrict(per_branch.TestCaseWithBranch):