~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.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:
169
169
        self.assertEqual(btree.path2id("grandparent/parent"), "b")
170
170
        self.assertEqual(btree.path2id("grandparent/parent/file"), "c")
171
171
 
172
 
        assert btree.path2id("grandparent2") is None
173
 
        assert btree.path2id("grandparent2/parent") is None
174
 
        assert btree.path2id("grandparent2/parent/file") is None
 
172
        self.assertTrue(btree.path2id("grandparent2") is None)
 
173
        self.assertTrue(btree.path2id("grandparent2/parent") is None)
 
174
        self.assertTrue(btree.path2id("grandparent2/parent/file") is None)
175
175
 
176
176
        btree.note_rename("grandparent", "grandparent2")
177
 
        assert btree.old_path("grandparent") is None
178
 
        assert btree.old_path("grandparent/parent") is None
179
 
        assert btree.old_path("grandparent/parent/file") is None
 
177
        self.assertTrue(btree.old_path("grandparent") is None)
 
178
        self.assertTrue(btree.old_path("grandparent/parent") is None)
 
179
        self.assertTrue(btree.old_path("grandparent/parent/file") is None)
180
180
 
181
181
        self.assertEqual(btree.id2path("a"), "grandparent2")
182
182
        self.assertEqual(btree.id2path("b"), "grandparent2/parent")
186
186
        self.assertEqual(btree.path2id("grandparent2/parent"), "b")
187
187
        self.assertEqual(btree.path2id("grandparent2/parent/file"), "c")
188
188
 
189
 
        assert btree.path2id("grandparent") is None
190
 
        assert btree.path2id("grandparent/parent") is None
191
 
        assert btree.path2id("grandparent/parent/file") is None
 
189
        self.assertTrue(btree.path2id("grandparent") is None)
 
190
        self.assertTrue(btree.path2id("grandparent/parent") is None)
 
191
        self.assertTrue(btree.path2id("grandparent/parent/file") is None)
192
192
 
193
193
        btree.note_rename("grandparent/parent", "grandparent2/parent2")
194
194
        self.assertEqual(btree.id2path("a"), "grandparent2")
199
199
        self.assertEqual(btree.path2id("grandparent2/parent2"), "b")
200
200
        self.assertEqual(btree.path2id("grandparent2/parent2/file"), "c")
201
201
 
202
 
        assert btree.path2id("grandparent2/parent") is None
203
 
        assert btree.path2id("grandparent2/parent/file") is None
 
202
        self.assertTrue(btree.path2id("grandparent2/parent") is None)
 
203
        self.assertTrue(btree.path2id("grandparent2/parent/file") is None)
204
204
 
205
205
        btree.note_rename("grandparent/parent/file", 
206
206
                          "grandparent2/parent2/file2")
212
212
        self.assertEqual(btree.path2id("grandparent2/parent2"), "b")
213
213
        self.assertEqual(btree.path2id("grandparent2/parent2/file2"), "c")
214
214
 
215
 
        assert btree.path2id("grandparent2/parent2/file") is None
 
215
        self.assertTrue(btree.path2id("grandparent2/parent2/file") is None)
216
216
 
217
217
    def test_moves(self):
218
218
        """Ensure that file moves have the proper effect on children"""
221
221
                          "grandparent/alt_parent/file")
222
222
        self.assertEqual(btree.id2path("c"), "grandparent/alt_parent/file")
223
223
        self.assertEqual(btree.path2id("grandparent/alt_parent/file"), "c")
224
 
        assert btree.path2id("grandparent/parent/file") is None
 
224
        self.assertTrue(btree.path2id("grandparent/parent/file") is None)
225
225
 
226
226
    def unified_diff(self, old, new):
227
227
        out = StringIO()
233
233
        btree = self.make_tree_1()[0]
234
234
        btree.note_rename("grandparent/parent/file", 
235
235
                          "grandparent/alt_parent/file")
236
 
        assert btree.id2path("e") is None
237
 
        assert btree.path2id("grandparent/parent/file") is None
 
236
        self.assertTrue(btree.id2path("e") is None)
 
237
        self.assertTrue(btree.path2id("grandparent/parent/file") is None)
238
238
        btree.note_id("e", "grandparent/parent/file")
239
239
        return btree
240
240
 
298
298
        btree = self.make_tree_1()[0]
299
299
        self.assertEqual(btree.get_file("c").read(), "Hello\n")
300
300
        btree.note_deletion("grandparent/parent/file")
301
 
        assert btree.id2path("c") is None
302
 
        assert btree.path2id("grandparent/parent/file") is None
 
301
        self.assertTrue(btree.id2path("c") is None)
 
302
        self.assertTrue(btree.path2id("grandparent/parent/file") is None)
303
303
 
304
304
    def sorted_ids(self, tree):
305
305
        ids = list(tree)
464
464
        ancestors = write_bundle(self.b1.repository, rev_id, 'null:', s,
465
465
                                 format=self.format)
466
466
        s.seek(0)
467
 
        assert isinstance(s.getvalue(), str), (
468
 
            "Bundle isn't a bytestring:\n %s..." % repr(s.getvalue())[:40])
 
467
        self.assertIsInstance(s.getvalue(), str)
469
468
        install_bundle(tree.branch.repository, read_bundle(s))
470
469
        for ancestor in ancestors:
471
470
            old = self.b1.repository.revision_tree(ancestor)