/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2008, 2009, 2010, 2016 Canonical Ltd
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
2
# -*- coding: utf-8 -*-
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
17
18
6622.1.29 by Jelmer Vernooij
Fix some more tests.
19
"""Black-box tests for 'brz modified', which shows modified files."""
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
20
21
import os
22
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy.branch import Branch
24
from breezy.tests import TestCaseWithTransport
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
25
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
26
class TestModified(TestCaseWithTransport):
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
27
28
    def test_modified(self):
29
        """Test that 'modified' command reports modified files"""
30
        self._test_modified('a', 'a')
31
32
    def test_modified_with_spaces(self):
33
        """Test that 'modified' command reports modified files with spaces in their names quoted"""
34
        self._test_modified('a filename with spaces', '"a filename with spaces"')
35
36
    def _test_modified(self, name, output):
37
38
        def check_modified(expected, null=False):
39
            command = 'modified'
40
            if null:
41
                command += ' --null'
42
            out, err = self.run_bzr(command)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
43
            self.assertEqual(out, expected)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
44
            self.assertEqual(err, '')
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
45
46
        # in empty directory, nothing modified
47
        tree = self.make_branch_and_tree('.')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
48
        check_modified('')
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
49
50
        # with unknown file, still nothing modified
7027.10.1 by Jelmer Vernooij
Various blackbox test fixes.
51
        self.build_tree_contents([(name, b'contents of %s\n' % (name.encode('utf-8')))])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
52
        check_modified('')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
53
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
54
        # after add, not modified
55
        tree.add(name)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
56
        check_modified('')
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
57
58
        # after commit, not modified
59
        tree.commit(message='add %s' % output)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
60
        check_modified('')
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
61
62
        # modify the file
6855.4.1 by Jelmer Vernooij
Yet more bees.
63
        self.build_tree_contents([(name, b'changed\n')])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
64
        check_modified(output + '\n')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
65
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
66
        # check null seps - use the unquoted raw name here
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
67
        check_modified(name + '\0', null=True)
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
68
69
        # now commit the file and it's no longer modified
70
        tree.commit(message='modified %s' %(name))
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
71
        check_modified('')
3251.6.6 by John Arbash Meinel
Fix the line endings of bzrlib.tests.blackbox.test_modified, they were dos, should be unix
72
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
73
    def test_modified_directory(self):
74
        """Test --directory option"""
75
        tree = self.make_branch_and_tree('a')
76
        self.build_tree(['a/README'])
77
        tree.add('README')
78
        tree.commit('r1')
6855.4.1 by Jelmer Vernooij
Yet more bees.
79
        self.build_tree_contents([('a/README', b'changed\n')])
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
80
        out, err = self.run_bzr(['modified', '--directory=a'])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
81
        self.assertEqual('README\n', out)