~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ignores.py

  • Committer: Gordon Tyler
  • Date: 2010-05-03 04:51:58 UTC
  • mto: This revision was merged to the branch mainline in revision 5207.
  • Revision ID: gordon@doxxx.net-20100503045158-q9smvxm7oelm8nm5
Fixed preservation of existing line endings and added tests for that and Unicode handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
class TestTreeIgnores(TestCaseWithTransport):
168
168
    
169
169
    def assertPatternsEquals(self, patterns):
170
 
        self.assertEquals(sorted(patterns),
171
 
                          sorted(open(".bzrignore", 'r').read().strip().split('\n')))
 
170
        contents = open(".bzrignore", 'rU').read().strip().split('\n')
 
171
        self.assertEquals(sorted(patterns), sorted(contents))
172
172
 
173
173
    def test_new_file(self):
174
174
        tree = self.make_branch_and_tree(".")
200
200
        tree.add([".bzrignore"])
201
201
        ignores.tree_ignores_add_patterns(tree, ["myentry"])
202
202
        self.assertPatternsEquals(["myentry"])
 
203
 
 
204
    def test_non_ascii(self):
 
205
        tree = self.make_branch_and_tree(".")
 
206
        self.build_tree_contents([('.bzrignore',
 
207
                                   u"myentry\u1234\n".encode('utf-8'))])
 
208
        tree.add([".bzrignore"])
 
209
        ignores.tree_ignores_add_patterns(tree, [u"myentry\u5678"])
 
210
        self.assertPatternsEquals([u"myentry\u1234".encode('utf-8'),
 
211
                                   u"myentry\u5678".encode('utf-8')])
 
212
 
 
213
    def test_crlf(self):
 
214
        tree = self.make_branch_and_tree(".")
 
215
        self.build_tree_contents([('.bzrignore', "myentry1\r\n")])
 
216
        tree.add([".bzrignore"])
 
217
        ignores.tree_ignores_add_patterns(tree, ["myentry2", "foo"])
 
218
        self.assertEquals(open('.bzrignore', 'rb').read(), 'myentry1\r\nmyentry2\r\nfoo\r\n')
 
219
        self.assertPatternsEquals(["myentry1", "myentry2", "foo"])