/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_ignores.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for handling of ignore files"""
18
18
 
19
 
from cStringIO import StringIO
20
 
 
21
 
from bzrlib import (
 
19
from .. import (
22
20
    config,
23
21
    ignores,
24
22
    )
25
 
from bzrlib.tests import (
 
23
from ..sixish import (
 
24
    BytesIO,
 
25
    )
 
26
from . import (
26
27
    TestCase,
27
28
    TestCaseInTempDir,
28
29
    TestCaseWithTransport,
32
33
class TestParseIgnoreFile(TestCase):
33
34
 
34
35
    def test_parse_fancy(self):
35
 
        ignored = ignores.parse_ignore_file(StringIO(
 
36
        ignored = ignores.parse_ignore_file(BytesIO(
36
37
                './rootdir\n'
37
38
                'randomfile*\n'
38
39
                'path/from/ro?t\n'
44
45
                '!RE:^\.z.*\n'
45
46
                '!!./.zcompdump\n'
46
47
                ))
47
 
        self.assertEqual(set(['./rootdir',
 
48
        self.assertEqual({'./rootdir',
48
49
                          'randomfile*',
49
50
                          'path/from/ro?t',
50
51
                          u'unicode\xb5',
52
53
                          ' xx ',
53
54
                          '!RE:^\.z.*',
54
55
                          '!!./.zcompdump',
55
 
                         ]), ignored)
 
56
                         }, ignored)
56
57
 
57
58
    def test_parse_empty(self):
58
 
        ignored = ignores.parse_ignore_file(StringIO(''))
 
59
        ignored = ignores.parse_ignore_file(BytesIO(b''))
59
60
        self.assertEqual(set([]), ignored)
60
61
        
61
62
    def test_parse_non_utf8(self):
62
63
        """Lines with non utf 8 characters should be discarded."""
63
 
        ignored = ignores.parse_ignore_file(StringIO(
 
64
        ignored = ignores.parse_ignore_file(BytesIO(
64
65
                'utf8filename_a\n'
65
66
                'invalid utf8\x80\n'
66
67
                'utf8filename_b\n'
67
68
                ))
68
 
        self.assertEqual(set([
 
69
        self.assertEqual({
69
70
                        'utf8filename_a',
70
71
                        'utf8filename_b',
71
 
                       ]), ignored)
 
72
                       }, ignored)
72
73
 
73
74
 
74
75
class TestUserIgnores(TestCaseInTempDir):
141
142
        added = ignores.add_unique_user_ignores(
142
143
            ['xxx', './bar', 'xxx', 'dir1/', 'dir2/', 'dir3\\'])
143
144
        self.assertEqual(['xxx', 'dir2'], added)
144
 
        self.assertEqual(set(['foo', './bar', u'b\xe5z',
145
 
                              'xxx', 'dir1', 'dir2', 'dir3']),
 
145
        self.assertEqual({'foo', './bar', u'b\xe5z',
 
146
                              'xxx', 'dir1', 'dir2', 'dir3'},
146
147
                         ignores.get_user_ignores())
147
148
 
148
149
 
160
161
        self.assertEqual(set(), ignores.get_runtime_ignores())
161
162
 
162
163
        ignores.add_runtime_ignores(['foo'])
163
 
        self.assertEqual(set(['foo']), ignores.get_runtime_ignores())
 
164
        self.assertEqual({'foo'}, ignores.get_runtime_ignores())
164
165
 
165
166
    def test_add_duplicate(self):
166
167
        """Adding the same ignore twice shouldn't add a new entry."""
167
168
        ignores.add_runtime_ignores(['foo', 'bar'])
168
 
        self.assertEqual(set(['foo', 'bar']), ignores.get_runtime_ignores())
 
169
        self.assertEqual({'foo', 'bar'}, ignores.get_runtime_ignores())
169
170
 
170
171
        ignores.add_runtime_ignores(['bar'])
171
 
        self.assertEqual(set(['foo', 'bar']), ignores.get_runtime_ignores())
 
172
        self.assertEqual({'foo', 'bar'}, ignores.get_runtime_ignores())
172
173
 
173
174
 
174
175
class TestTreeIgnores(TestCaseWithTransport):