~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_branch.py

  • Committer: A. S. Budden
  • Date: 2011-05-04 13:24:40 UTC
  • mto: (5816.6.16 bazaar_source)
  • mto: This revision was merged to the branch mainline in revision 5835.
  • Revision ID: abudden@gmail.com-20110504132440-2f7jsj241p1pf22e
Check parent branch of both the checkout (light or heavy) and the branch to which it is connected.

Show diffs side-by-side

added added

removed removed

Lines of Context:
537
537
                Using shared repository: ...
538
538
                ''')
539
539
 
540
 
    def assertParentCorrect(self, branch, expected_parent):
 
540
    def assertParentCorrect(self, branch, expected_parent, name):
541
541
        """Verify that the parent is not None and is set correctly."""
542
542
        actual_parent = branch.get_parent()
543
 
        self.assertIsNot(actual_parent, None, "Parent not set")
 
543
        self.assertIsNot(actual_parent, None, name + "Parent not set")
544
544
        expected = urlutils.strip_trailing_slash(urlutils.normalize_url(expected_parent))
545
545
        actual = urlutils.strip_trailing_slash(urlutils.normalize_url(actual_parent))
546
 
        self.assertEquals(expected, actual, "Parent set incorrectly")
 
546
        self.assertEquals(expected, actual, name + "Parent set incorrectly")
547
547
 
548
548
    def _create_checkout_and_branch(self, option, suffix):
549
549
        self.script_runner.run_script(self, '''
555
555
                2>Switched to branch:...branched_%(suffix)s...
556
556
                $ cd ..
557
557
                ''' % locals())
558
 
        return branch.Branch.open_containing('work_%(suffix)s_branch' % locals())[0]
 
558
        bound_branch = branch.Branch.open_containing('work_%(suffix)s_branch' % locals())[0]
 
559
        master_branch = branch.Branch.open_containing('repo/branched_%(suffix)s' % locals())[0]
 
560
        return (bound_branch, master_branch)
559
561
 
560
562
    def test_branch_switch_parent_lightweight(self):
561
563
        """Verify parent directory for lightweight checkout using bzr branch --switch."""
562
 
        b = self._create_checkout_and_branch(option='--lightweight', suffix='lw')
563
 
        self.assertParentCorrect(b, urlutils.local_path_to_url('repo/trunk'))
 
564
        bb, mb = self._create_checkout_and_branch(option='--lightweight', suffix='lw')
 
565
        self.assertParentCorrect(bb, urlutils.local_path_to_url('repo/trunk'), "Checkout")
 
566
        self.assertParentCorrect(mb, urlutils.local_path_to_url('repo/trunk'), "Master Branch")
564
567
 
565
568
    def test_branch_switch_parent_heavyweight(self):
566
569
        """Verify parent directory for heavyweight checkout using bzr branch --switch."""
567
 
        b = self._create_checkout_and_branch(option='', suffix='hw')
568
 
        self.assertParentCorrect(b, urlutils.local_path_to_url('repo/trunk'))
 
570
        bb, mb = self._create_checkout_and_branch(option='', suffix='hw')
 
571
        self.assertParentCorrect(bb, urlutils.local_path_to_url('repo/trunk'), "Bound Branch")
 
572
        self.assertParentCorrect(mb, urlutils.local_path_to_url('repo/trunk'), "Master Branch")