/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/test_ignores.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
    def test_parse_fancy(self):
36
36
        ignored = ignores.parse_ignore_file(BytesIO(
37
 
                b'./rootdir\n'
38
 
                b'randomfile*\n'
39
 
                b'path/from/ro?t\n'
40
 
                b'unicode\xc2\xb5\n' # u'\xb5'.encode('utf8')
41
 
                b'dos\r\n'
42
 
                b'\n' # empty line
43
 
                b'#comment\n'
44
 
                b' xx \n' # whitespace
45
 
                b'!RE:^\\.z.*\n'
46
 
                b'!!./.zcompdump\n'
47
 
                ))
 
37
            b'./rootdir\n'
 
38
            b'randomfile*\n'
 
39
            b'path/from/ro?t\n'
 
40
            b'unicode\xc2\xb5\n'  # u'\xb5'.encode('utf8')
 
41
            b'dos\r\n'
 
42
            b'\n'  # empty line
 
43
            b'#comment\n'
 
44
            b' xx \n'  # whitespace
 
45
            b'!RE:^\\.z.*\n'
 
46
            b'!!./.zcompdump\n'
 
47
            ))
48
48
        self.assertEqual({u'./rootdir',
49
49
                          u'randomfile*',
50
50
                          u'path/from/ro?t',
53
53
                          u' xx ',
54
54
                          u'!RE:^\\.z.*',
55
55
                          u'!!./.zcompdump',
56
 
                         }, ignored)
 
56
                          }, ignored)
57
57
 
58
58
    def test_parse_empty(self):
59
59
        ignored = ignores.parse_ignore_file(BytesIO(b''))
60
60
        self.assertEqual(set([]), ignored)
61
 
        
 
61
 
62
62
    def test_parse_non_utf8(self):
63
63
        """Lines with non utf 8 characters should be discarded."""
64
64
        ignored = ignores.parse_ignore_file(BytesIO(
65
 
                b'utf8filename_a\n'
66
 
                b'invalid utf8\x80\n'
67
 
                b'utf8filename_b\n'
68
 
                ))
 
65
            b'utf8filename_a\n'
 
66
            b'invalid utf8\x80\n'
 
67
            b'utf8filename_b\n'
 
68
            ))
69
69
        self.assertEqual({
70
 
                        u'utf8filename_a',
71
 
                        u'utf8filename_b',
72
 
                       }, ignored)
 
70
            u'utf8filename_a',
 
71
            u'utf8filename_b',
 
72
            }, ignored)
73
73
 
74
74
 
75
75
class TestUserIgnores(TestCaseInTempDir):
127
127
 
128
128
        in_patterns = ['foo/', 'bar/', 'baz\\']
129
129
        added = ignores.add_unique_user_ignores(in_patterns)
130
 
        out_patterns = [ x.rstrip('/\\') for x in in_patterns ]
 
130
        out_patterns = [x.rstrip('/\\') for x in in_patterns]
131
131
        self.assertEqual(out_patterns, added)
132
132
        self.assertEqual(set(out_patterns), ignores.get_user_ignores())
133
133
 
140
140
            ['xxx', './bar', 'xxx', 'dir1/', 'dir2/', 'dir3\\'])
141
141
        self.assertEqual(['xxx', 'dir2'], added)
142
142
        self.assertEqual({'foo', './bar', u'b\xe5z',
143
 
                              'xxx', 'dir1', 'dir2', 'dir3'},
 
143
                          'xxx', 'dir1', 'dir2', 'dir3'},
144
144
                         ignores.get_user_ignores())
145
145
 
146
146