~bzr-pqm/bzr/bzr.dev

1185.14.8 by Aaron Bentley
Added test_commit.py
1
# Copyright (C) 2005 by Canonical Ltd
2
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
18
import os
19
20
from bzrlib.selftest import TestCaseInTempDir
21
from bzrlib.branch import Branch
22
from bzrlib.commit import Commit
23
24
25
# TODO: Test commit with some added, and added-but-missing files
26
27
class TestConflicts(TestCaseInTempDir):
28
29
    def test_conflicts(self):
30
        """Conflicts are detected properly"""
31
        b = Branch.initialize('.')
32
        file('hello', 'w').write('hello world')
33
        file('hello.BASE', 'w').write('hello world')
34
        file('hello.sploo.BASE', 'w').write('yellow world')
35
        tree = b.working_tree()
36
        self.assertEqual(len(list(tree.list_files())), 3)
37
        conflicts = list(tree.iter_conflicts())
38
        self.assertEqual(len(conflicts), 2)
39
        assert 'hello' in conflicts
40
        assert 'hello.sploo' in conflicts
41
        os.unlink('hello.BASE')
42
        os.unlink('hello.sploo.BASE')
43
        self.assertEqual(len(list(tree.iter_conflicts())), 0)
44