~bzr-pqm/bzr/bzr.dev

6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2007, 2009-2012, 2016 Canonical Ltd
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
16
17
"""Test that we can use smart_add on all Tree implementations."""
18
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
19
from cStringIO import StringIO
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
20
import os
4789.11.1 by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows.
21
import sys
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
22
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
23
from bzrlib import (
24
    errors,
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
25
    ignores,
26
    osutils,
2568.2.10 by Robert Collins
And a missing import.
27
    tests,
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
28
    trace,
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
29
    )
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
30
from bzrlib.tests import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
31
    features,
32
    per_workingtree,
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
33
    test_smart_add,
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
34
    )
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
35
36
37
class TestSmartAddTree(per_workingtree.TestCaseWithWorkingTree):
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
38
39
    def test_single_file(self):
40
        tree = self.make_branch_and_tree('tree')
41
        self.build_tree(['tree/a'])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
42
        tree.smart_add(['tree'])
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
43
44
        tree.lock_read()
45
        try:
46
            files = [(path, status, kind)
47
                     for path, status, kind, file_id, parent_id
48
                      in tree.list_files(include_root=True)]
49
        finally:
50
            tree.unlock()
51
        self.assertEqual([('', 'V', 'directory'), ('a', 'V', 'file')],
52
                         files)
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
53
4634.55.1 by Robert Collins
Do not add files whose name contains new lines or carriage returns
54
    def assertFilenameSkipped(self, filename):
55
        tree = self.make_branch_and_tree('tree')
4789.11.1 by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows.
56
        try:
57
            self.build_tree(['tree/'+filename])
58
        except errors.NoSuchFile:
59
            if sys.platform == 'win32':
60
                raise tests.TestNotApplicable('Cannot create files named %r on'
61
                    ' win32' % (filename,))
4634.55.1 by Robert Collins
Do not add files whose name contains new lines or carriage returns
62
        tree.smart_add(['tree'])
63
        self.assertEqual(None, tree.path2id(filename))
64
65
    def test_path_containing_newline_skips(self):
66
        self.assertFilenameSkipped('a\nb')
67
68
    def test_path_containing_carriagereturn_skips(self):
69
        self.assertFilenameSkipped('a\rb')
70
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
71
    def test_save_false(self):
72
        """Dry-run add doesn't permanently affect the tree."""
73
        wt = self.make_branch_and_tree('.')
2585.1.1 by Aaron Bentley
Unify MutableTree.smart_add behavior by disabling quirky memory-only Inventory
74
        wt.lock_write()
75
        try:
76
            self.build_tree(['file'])
77
            wt.smart_add(['file'], save=False)
78
            # the file should not be added - no id.
79
            self.assertEqual(wt.path2id('file'), None)
80
        finally:
81
            wt.unlock()
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
82
        # and the disk state should be the same - reopen to check.
2255.7.92 by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract.
83
        wt = wt.bzrdir.open_workingtree()
84
        self.assertEqual(wt.path2id('file'), None)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
85
86
    def test_add_dot_from_root(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
87
        """Test adding . from the root of the tree."""
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
88
        paths = ("original/", "original/file1", "original/file2")
89
        self.build_tree(paths)
90
        wt = self.make_branch_and_tree('.')
91
        wt.smart_add((u".",))
92
        for path in paths:
93
            self.assertNotEqual(wt.path2id(path), None)
94
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
95
    def test_skip_nested_trees(self):
96
        """Test smart-adding a nested tree ignors it and warns."""
97
        wt = self.make_branch_and_tree('.')
98
        nested_wt = self.make_branch_and_tree('nested')
99
        warnings = []
100
        def warning(*args):
101
            warnings.append(args[0] % args[1:])
102
        self.overrideAttr(trace, 'warning', warning)
103
        wt.smart_add((u".",))
104
        self.assertIs(wt.path2id("nested"), None)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
105
        self.assertEqual(
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
106
            ['skipping nested tree %r' % nested_wt.basedir], warnings)
107
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
108
    def test_add_dot_from_subdir(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
109
        """Test adding . from a subdir of the tree."""
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
110
        paths = ("original/", "original/file1", "original/file2")
111
        self.build_tree(paths)
112
        wt = self.make_branch_and_tree('.')
113
        wt.smart_add((u".",))
114
        for path in paths:
115
            self.assertNotEqual(wt.path2id(path), None)
116
117
    def test_add_tree_from_above_tree(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
118
        """Test adding a tree from above the tree."""
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
119
        paths = ("original/", "original/file1", "original/file2")
120
        branch_paths = ("branch/", "branch/original/", "branch/original/file1",
121
                        "branch/original/file2")
122
        self.build_tree(branch_paths)
123
        wt = self.make_branch_and_tree('branch')
124
        wt.smart_add(("branch",))
125
        for path in paths:
126
            self.assertNotEqual(wt.path2id(path), None)
127
128
    def test_add_above_tree_preserves_tree(self):
129
        """Test nested trees are not affect by an add above them."""
130
        paths = ("original/", "original/file1", "original/file2")
131
        child_paths = ("path",)
132
        full_child_paths = ("original/child", "original/child/path")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
133
        build_paths = ("original/", "original/file1", "original/file2",
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
134
                       "original/child/", "original/child/path")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
135
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
136
        self.build_tree(build_paths)
137
        wt = self.make_branch_and_tree('.')
6437.70.6 by John Arbash Meinel
Fix a couple tests that wanted to directly create a wt where the branch was.
138
        if wt.user_url != wt.branch.user_url:
139
            # Lightweight checkout, make sure we have a repo location.
140
            wt.branch.bzrdir.root_transport.mkdir('original')
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
141
        child_tree = self.make_branch_and_tree('original/child')
142
        wt.smart_add((".",))
143
        for path in paths:
144
            self.assertNotEqual((path, wt.path2id(path)),
145
                                (path, None))
146
        for path in full_child_paths:
147
            self.assertEqual((path, wt.path2id(path)),
148
                             (path, None))
149
        for path in child_paths:
150
            self.assertEqual(child_tree.path2id(path), None)
151
152
    def test_add_paths(self):
153
        """Test smart-adding a list of paths."""
154
        paths = ("file1", "file2")
155
        self.build_tree(paths)
156
        wt = self.make_branch_and_tree('.')
157
        wt.smart_add(paths)
158
        for path in paths:
159
            self.assertNotEqual(wt.path2id(path), None)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
160
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
161
    def test_add_ignored_nested_paths(self):
162
        """Test smart-adding a list of paths which includes ignored ones."""
163
        wt = self.make_branch_and_tree('.')
164
        tree_shape = ("adir/", "adir/CVS/", "adir/CVS/afile", "adir/CVS/afile2")
165
        add_paths = ("adir/CVS", "adir/CVS/afile", "adir")
166
        expected_paths = ("adir", "adir/CVS", "adir/CVS/afile", "adir/CVS/afile2")
167
        self.build_tree(tree_shape)
168
        wt.smart_add(add_paths)
169
        for path in expected_paths:
6123.10.1 by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped.
170
            self.assertNotEqual(wt.path2id(path), None,
171
                "No id added for %s" % path)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
172
173
    def test_add_non_existant(self):
174
        """Test smart-adding a file that does not exist."""
175
        wt = self.make_branch_and_tree('.')
176
        self.assertRaises(errors.NoSuchFile, wt.smart_add, ['non-existant-file'])
177
178
    def test_returns_and_ignores(self):
179
        """Correctly returns added/ignored files"""
180
        wt = self.make_branch_and_tree('.')
181
        # The default ignore list includes '*.py[co]', but not CVS
182
        ignores._set_user_ignores(['*.py[co]'])
183
        self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
184
                        'inertiatic/foo.pyc'])
185
        added, ignored = wt.smart_add(u'.')
186
        self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'),
187
                          added)
188
        self.assertSubset(('*.py[co]',), ignored)
189
        self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[co]'])
190
191
    def test_add_multiple_dirs(self):
192
        """Test smart adding multiple directories at once."""
193
        added_paths = ['file1', 'file2',
194
                       'dir1/', 'dir1/file3',
195
                       'dir1/subdir2/', 'dir1/subdir2/file4',
196
                       'dir2/', 'dir2/file5',
197
                      ]
198
        not_added = ['file6', 'dir3/', 'dir3/file7', 'dir3/file8']
199
        self.build_tree(added_paths)
200
        self.build_tree(not_added)
201
202
        wt = self.make_branch_and_tree('.')
203
        wt.smart_add(['file1', 'file2', 'dir1', 'dir2'])
204
205
        for path in added_paths:
206
            self.assertNotEqual(None, wt.path2id(path.rstrip('/')),
207
                    'Failed to add path: %s' % (path,))
208
        for path in not_added:
209
            self.assertEqual(None, wt.path2id(path.rstrip('/')),
210
                    'Accidentally added path: %s' % (path,))
211
4163.2.1 by Ian Clatworthy
Fix add in trees supports views
212
    def test_add_file_in_unknown_dir(self):
213
        # Test that parent directory addition is implicit
214
        tree = self.make_branch_and_tree('.')
215
        self.build_tree(['dir/', 'dir/subdir/', 'dir/subdir/foo'])
216
        tree.smart_add(['dir/subdir/foo'])
217
        tree.lock_read()
218
        self.addCleanup(tree.unlock)
219
        self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'],
220
            [path for path, ie in tree.iter_entries_by_dir()])
221
5504.6.2 by Martin
If a dir being added used to be something else detect and correct
222
    def test_add_dir_bug_251864(self):
5504.6.3 by Martin
Address poolie's review, mention both bugs in test and add news
223
        """Added file turning into a dir should be detected on add dir
224
225
        Similar to bug 205636 but with automatic adding of directory contents.
226
        """
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
227
        tree = self.make_branch_and_tree(".")
228
        self.build_tree(["dir"]) # whoops, make a file called dir
229
        tree.smart_add(["dir"])
230
        os.remove("dir")
231
        self.build_tree(["dir/", "dir/file"])
5504.6.2 by Martin
If a dir being added used to be something else detect and correct
232
        tree.smart_add(["dir"])
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
233
        tree.commit("Add dir contents")
5378.1.4 by Martin
Assert state of the tree after add and commit in new tests
234
        self.addCleanup(tree.lock_read().unlock)
235
        self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")],
236
            [(t[0], t[2]) for t in tree.list_files()])
237
        self.assertFalse(list(tree.iter_changes(tree.basis_tree())))
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
238
239
    def test_add_subdir_file_bug_205636(self):
240
        """Added file turning into a dir should be detected on add dir/file"""
241
        tree = self.make_branch_and_tree(".")
242
        self.build_tree(["dir"]) # whoops, make a file called dir
243
        tree.smart_add(["dir"])
244
        os.remove("dir")
245
        self.build_tree(["dir/", "dir/file"])
5378.1.3 by Martin
Note that TestSmartAddTree.test_add_subdir_file_bug_205636 now passes
246
        tree.smart_add(["dir/file"])
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
247
        tree.commit("Add file in dir")
5378.1.4 by Martin
Assert state of the tree after add and commit in new tests
248
        self.addCleanup(tree.lock_read().unlock)
249
        self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")],
250
            [(t[0], t[2]) for t in tree.list_files()])
251
        self.assertFalse(list(tree.iter_changes(tree.basis_tree())))
5378.1.1 by Martin
Add per_workingtree tests in add and smart_add for bug 205636
252
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
253
    def test_custom_ids(self):
254
        sio = StringIO()
5013.2.2 by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py.
255
        action = test_smart_add.AddCustomIDAction(to_file=sio,
256
                                                  should_print=True)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
257
        self.build_tree(['file1', 'dir1/', 'dir1/file2'])
258
259
        wt = self.make_branch_and_tree('.')
260
        wt.smart_add(['.'], action=action)
261
        # The order of adds is not strictly fixed:
262
        sio.seek(0)
263
        lines = sorted(sio.readlines())
3985.2.5 by Daniel Watkins
Reverted some irrelevant changes.
264
        self.assertEqualDiff(['added dir1 with id directory-dir1\n',
265
                              'added dir1/file2 with id file-dir1%file2\n',
266
                              'added file1 with id file-file1\n',
267
                             ], lines)
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
268
        wt.lock_read()
269
        self.addCleanup(wt.unlock)
270
        self.assertEqual([('', wt.path2id('')),
271
                          ('dir1', 'directory-dir1'),
5807.1.8 by Jelmer Vernooij
Fix some tests.
272
                          ('file1', 'file-file1'),
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
273
                          ('dir1/file2', 'file-dir1%file2'),
274
                         ], [(path, ie.file_id) for path, ie
5807.1.8 by Jelmer Vernooij
Fix some tests.
275
                                in wt.iter_entries_by_dir()])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
276
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
277
5013.2.4 by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files.
278
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
279
280
    def make_tree_with_text_conflict(self):
281
        tb = self.make_branch_and_tree('base')
282
        self.build_tree_contents([('base/file', 'content in base')])
283
        tb.add('file')
284
        tb.commit('Adding file')
285
286
        t1 = tb.bzrdir.sprout('t1').open_workingtree()
287
288
        self.build_tree_contents([('base/file', 'content changed in base')])
289
        tb.commit('Changing file in base')
290
291
        self.build_tree_contents([('t1/file', 'content in t1')])
292
        t1.commit('Changing file in t1')
293
        t1.merge_from_branch(tb.branch)
294
        return t1
295
296
    def test_cant_add_generated_files_implicitly(self):
297
        t = self.make_tree_with_text_conflict()
298
        added, ignored = t.smart_add([t.basedir])
299
        self.assertEqual(([], {}), (added, ignored))
300
301
    def test_can_add_generated_files_explicitly(self):
302
        fnames = ['file.%s' % s  for s in ('BASE', 'THIS', 'OTHER')]
303
        t = self.make_tree_with_text_conflict()
304
        added, ignored = t.smart_add([t.basedir + '/%s' % f for f in fnames])
305
        self.assertEqual((fnames, {}), (added, ignored))
306
307
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
308
class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree):
309
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
310
    _test_needs_features = [features.UnicodeFilenameFeature]
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
311
312
    def setUp(self):
313
        super(TestSmartAddTreeUnicode, self).setUp()
314
        self.build_tree([u'a\u030a'])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
315
        self.wt = self.make_branch_and_tree('.')
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
316
        self.overrideAttr(osutils, 'normalized_filename')
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
317
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
318
    def test_requires_normalized_unicode_filenames_fails_on_unnormalized(self):
319
        """Adding unnormalized unicode filenames fail if and only if the
320
        workingtree format has the requires_normalized_unicode_filenames flag
5929.1.1 by Vincent Ladeuil
Fix spurious test failure on OSX for WorkingTreeFormat2
321
        set and the underlying filesystem doesn't normalize.
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
322
        """
323
        osutils.normalized_filename = osutils._accessible_normalized_filename
5929.1.1 by Vincent Ladeuil
Fix spurious test failure on OSX for WorkingTreeFormat2
324
        if (self.workingtree_format.requires_normalized_unicode_filenames
325
            and sys.platform != 'darwin'):
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
326
            self.assertRaises(
327
                errors.NoSuchFile, self.wt.smart_add, [u'a\u030a'])
328
        else:
329
            self.wt.smart_add([u'a\u030a'])
330
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
331
    def test_accessible_explicit(self):
332
        osutils.normalized_filename = osutils._accessible_normalized_filename
5582.10.29 by Jelmer Vernooij
Add requires_normalized_unicode_filenames
333
        if self.workingtree_format.requires_normalized_unicode_filenames:
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
334
            raise tests.TestNotApplicable(
335
                'Working tree format smart_add requires normalized unicode '
336
                'filenames')
5868.1.1 by Martin
Turn two long-standing unexpected successes into skips
337
        self.wt.smart_add([u'a\u030a'])
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
338
        self.wt.lock_read()
339
        self.addCleanup(self.wt.unlock)
340
        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
341
                         [(path, ie.kind) for path,ie in
5807.1.8 by Jelmer Vernooij
Fix some tests.
342
                          self.wt.iter_entries_by_dir()])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
343
344
    def test_accessible_implicit(self):
345
        osutils.normalized_filename = osutils._accessible_normalized_filename
5582.10.29 by Jelmer Vernooij
Add requires_normalized_unicode_filenames
346
        if self.workingtree_format.requires_normalized_unicode_filenames:
5868.1.4 by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode.
347
            raise tests.TestNotApplicable(
348
                'Working tree format smart_add requires normalized unicode '
349
                'filenames')
5868.1.1 by Martin
Turn two long-standing unexpected successes into skips
350
        self.wt.smart_add([])
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
351
        self.wt.lock_read()
352
        self.addCleanup(self.wt.unlock)
353
        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
5013.2.6 by Vincent Ladeuil
WorkingTreeFormat2 don't support not normalized filenames.
354
                         [(path, ie.kind) for path,ie
5807.1.8 by Jelmer Vernooij
Fix some tests.
355
                          in self.wt.iter_entries_by_dir()])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
356
357
    def test_inaccessible_explicit(self):
358
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
359
        self.assertRaises(errors.InvalidNormalization,
360
                          self.wt.smart_add, [u'a\u030a'])
2568.2.4 by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now
361
362
    def test_inaccessible_implicit(self):
363
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
5013.2.3 by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py.
364
        # TODO: jam 20060701 In the future, this should probably
365
        #       just ignore files that don't fit the normalization
366
        #       rules, rather than exploding
367
        self.assertRaises(errors.InvalidNormalization, self.wt.smart_add, [])