/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_add_reference.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        sub_tree.commit('commit', rev_id='sub_1')
37
37
        return tree, sub_tree
38
38
 
 
39
    def _references_unsupported(self, tree):
 
40
        if tree.__class__ in TREES_NOT_SUPPORTING_REFERENCES:
 
41
            raise tests.TestSkipped('Tree format does not support references')
 
42
        else:
 
43
            self.fail('%r does not support references but should'
 
44
                % (tree, ))
 
45
 
39
46
    def make_nested_trees(self):
40
47
        tree, sub_tree = self.make_trees()
41
48
        try:
42
49
            tree.add_reference(sub_tree)
43
50
        except errors.UnsupportedOperation:
44
 
            assert tree.__class__ in TREES_NOT_SUPPORTING_REFERENCES
45
 
            raise tests.TestSkipped('Tree format does not support references')
 
51
            self._references_unsupported(tree)
46
52
        return tree, sub_tree
47
53
 
48
54
    def test_add_reference(self):
76
82
            self.assertRaises(errors.BadReferenceTarget, tree.add_reference, 
77
83
                              sub_tree)
78
84
        except errors.UnsupportedOperation:
79
 
            assert tree.__class__ in TREES_NOT_SUPPORTING_REFERENCES
80
 
            raise tests.TestSkipped('Tree format does not support references')
 
85
            self._references_unsupported(tree)
81
86
 
82
87
    def test_root_present(self):
83
88
        """Subtree root is present, though not the working tree root"""
87
92
            self.assertRaises(errors.BadReferenceTarget, tree.add_reference, 
88
93
                              sub_tree)
89
94
        except errors.UnsupportedOperation:
90
 
            assert tree.__class__ in TREES_NOT_SUPPORTING_REFERENCES
91
 
            raise tests.TestSkipped('Tree format does not support references')
 
95
            self._references_unsupported(tree)
92
96
 
93
97
    def test_add_non_subtree(self):
94
98
        tree, sub_tree = self.make_trees()
98
102
            self.assertRaises(errors.BadReferenceTarget, tree.add_reference, 
99
103
                              sibling)
100
104
        except errors.UnsupportedOperation:
101
 
            assert tree.__class__ in TREES_NOT_SUPPORTING_REFERENCES
102
 
            raise tests.TestSkipped('Tree format does not support references')
 
105
            self._references_unsupported(tree)
103
106
 
104
107
    def test_get_nested_tree(self):
105
108
        tree, sub_tree = self.make_nested_trees()