/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/test_conflicts.py

  • Committer: Vincent Ladeuil
  • Date: 2010-03-02 07:38:15 UTC
  • mto: (5067.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5068.
  • Revision ID: v.ladeuil+lp@free.fr-20100302073815-0ymcuompxllxvvd0
Use assertLength where appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
                                  ('hello.sploo.OTHER', 'yellowworld2'),
87
87
                                  ])
88
88
        tree.lock_read()
89
 
        self.assertEqual(6, len(list(tree.list_files())))
 
89
        self.assertLength(6, list(tree.list_files()))
90
90
        tree.unlock()
91
91
        tree_conflicts = tree.conflicts()
92
 
        self.assertEqual(2, len(tree_conflicts))
 
92
        self.assertLength(2, tree_conflicts)
93
93
        self.assertTrue('hello' in tree_conflicts[0].path)
94
94
        self.assertTrue('hello.sploo' in tree_conflicts[1].path)
95
95
        conflicts.restore('hello')
96
96
        conflicts.restore('hello.sploo')
97
 
        self.assertEqual(0, len(tree.conflicts()))
 
97
        self.assertLength(0, tree.conflicts())
98
98
        self.assertFileEqual('hello world2', 'hello')
99
99
        self.assertFalse(os.path.lexists('hello.sploo'))
100
100
        self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello')
274
274
 
275
275
    def assertConflict(self, wt, ctype, **kwargs):
276
276
        confs = wt.conflicts()
277
 
        self.assertEqual(1, len(confs))
 
277
        self.assertLength(1, confs)
278
278
        c = confs[0]
279
279
        self.assertIsInstance(c, ctype)
280
280
        sentinel = object() # An impossible value
281
281
        for k, v in kwargs.iteritems():
282
282
            self.assertEqual(v, getattr(c, k, sentinel))
283
283
 
284
 
    def assertResolved(self, wt, item, action):
 
284
    def check_resolved(self, wt, item, action):
285
285
        conflicts.resolve(wt, [item], action=action)
286
286
        # Check that we don't have any conflicts nor unknown left
287
 
        self.assertEqual(0, len(wt.conflicts()))
288
 
        self.assertEqual(0, len(list(wt.unknowns())))
 
287
        self.assertLength(0, wt.conflicts())
 
288
        self.assertLength(0, list(wt.unknowns()))
289
289
 
290
290
    def test_resolve_taking_this(self):
291
291
        wt = self._merge_other_into_this()
292
292
        self.assertConflict(wt, conflicts.ContentsConflict,
293
293
                            path='file', file_id='file-id',)
294
 
        self.assertResolved(wt, 'file', 'take_this')
 
294
        self.check_resolved(wt, 'file', 'take_this')
295
295
        check_this = self._get_check(self._check_this)
296
296
        check_this()
297
297
 
299
299
        wt = self._merge_other_into_this()
300
300
        self.assertConflict(wt, conflicts.ContentsConflict,
301
301
                            path='file', file_id='file-id',)
302
 
        self.assertResolved(wt, 'file', 'take_other')
 
302
        self.check_resolved(wt, 'file', 'take_other')
303
303
        check_other = self._get_check(self._check_other)
304
304
        check_other()
305
305