/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 breezy/tests/blackbox/test_modified.py

  • Committer: John Arbash Meinel
  • Date: 2006-04-25 15:05:42 UTC
  • mfrom: (1185.85.85 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060425150542-c7b518dca9928691
[merge] the old bzr-encoding changes, reparenting them on bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010, 2016 Canonical Ltd
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
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 
 
18
 
 
19
 
"""Black-box tests for 'brz modified', which shows modified files."""
20
 
 
21
 
import os
22
 
 
23
 
from breezy.branch import Branch
24
 
from breezy.tests import TestCaseWithTransport
25
 
 
26
 
 
27
 
class TestModified(TestCaseWithTransport):
28
 
 
29
 
    def test_modified(self):
30
 
        """Test that 'modified' command reports modified files"""
31
 
        self._test_modified('a', 'a')
32
 
 
33
 
    def test_modified_with_spaces(self):
34
 
        """Test that 'modified' command reports modified files with spaces in their names quoted"""
35
 
        self._test_modified('a filename with spaces',
36
 
                            '"a filename with spaces"')
37
 
 
38
 
    def _test_modified(self, name, output):
39
 
 
40
 
        def check_modified(expected, null=False):
41
 
            command = 'modified'
42
 
            if null:
43
 
                command += ' --null'
44
 
            out, err = self.run_bzr(command)
45
 
            self.assertEqual(out, expected)
46
 
            self.assertEqual(err, '')
47
 
 
48
 
        # in empty directory, nothing modified
49
 
        tree = self.make_branch_and_tree('.')
50
 
        check_modified('')
51
 
 
52
 
        # with unknown file, still nothing modified
53
 
        self.build_tree_contents(
54
 
            [(name, b'contents of %s\n' % (name.encode('utf-8')))])
55
 
        check_modified('')
56
 
 
57
 
        # after add, not modified
58
 
        tree.add(name)
59
 
        check_modified('')
60
 
 
61
 
        # after commit, not modified
62
 
        tree.commit(message='add %s' % output)
63
 
        check_modified('')
64
 
 
65
 
        # modify the file
66
 
        self.build_tree_contents([(name, b'changed\n')])
67
 
        check_modified(output + '\n')
68
 
 
69
 
        # check null seps - use the unquoted raw name here
70
 
        check_modified(name + '\0', null=True)
71
 
 
72
 
        # now commit the file and it's no longer modified
73
 
        tree.commit(message='modified %s' % (name))
74
 
        check_modified('')
75
 
 
76
 
    def test_modified_directory(self):
77
 
        """Test --directory option"""
78
 
        tree = self.make_branch_and_tree('a')
79
 
        self.build_tree(['a/README'])
80
 
        tree.add('README')
81
 
        tree.commit('r1')
82
 
        self.build_tree_contents([('a/README', b'changed\n')])
83
 
        out, err = self.run_bzr(['modified', '--directory=a'])
84
 
        self.assertEqual('README\n', out)