~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ignores.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-20 22:14:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1877.
  • Revision ID: john@arbash-meinel.com-20060720221438-f91ad8cc36e0b576
Change ignore functions to use sets instead of lists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                '#comment\n'
36
36
                ' xx \n' # whitespace
37
37
                ))
38
 
        self.assertEqual(['./rootdir',
 
38
        self.assertEqual(set(['./rootdir',
39
39
                          'randomfile*',
40
40
                          'path/from/ro?t',
41
41
                          u'unicode\xb5',
42
42
                          'dos',
43
43
                          ' xx ',
44
 
                         ], ignored)
 
44
                         ]), ignored)
45
45
 
46
46
    def test_parse_empty(self):
47
47
        ignored = ignores.parse_ignore_file(StringIO(''))
48
 
        self.assertEqual([], ignored)
 
48
        self.assertEqual(set([]), ignored)
49
49
 
50
50
 
51
51
class TestUserIgnores(TestCaseInTempDir):
55
55
        ignore_path = config.user_ignore_config_filename()
56
56
        self.failIfExists(ignore_path)
57
57
        user_ignores = ignores.get_user_ignores()
58
 
        self.assertEqual(ignores.USER_DEFAULTS, user_ignores)
 
58
        self.assertEqual(set(ignores.USER_DEFAULTS), user_ignores)
59
59
 
60
60
        self.failUnlessExists(ignore_path)
61
61
        f = open(ignore_path, 'rb')
63
63
            entries = ignores.parse_ignore_file(f)
64
64
        finally:
65
65
            f.close()
66
 
        self.assertEqual(ignores.USER_DEFAULTS, user_ignores)
 
66
        self.assertEqual(set(ignores.USER_DEFAULTS), entries)
67
67
 
68
68
    def test_use_existing(self):
69
69
        patterns = ['*.o', '*.py[co]', u'\xe5*']
70
70
        ignores.set_user_ignores(patterns)
71
71
 
72
72
        user_ignores = ignores.get_user_ignores()
73
 
        self.assertEqual(patterns, user_ignores)
 
73
        self.assertEqual(set(patterns), user_ignores)
74
74
 
75
75
    def test_use_empty(self):
76
76
        ignores.set_user_ignores([])
77
77
        ignore_path = config.user_ignore_config_filename()
78
78
        self.check_file_contents(ignore_path, '')
79
79
 
80
 
        self.assertEqual([], ignores.get_user_ignores())
 
80
        self.assertEqual(set([]), ignores.get_user_ignores())
81
81
 
82
82
    def test_set(self):
83
83
        patterns = ['*.py[co]', '*.py[oc]']
84
84
        ignores.set_user_ignores(patterns)
85
85
 
86
 
        self.assertEqual(patterns, ignores.get_user_ignores())
 
86
        self.assertEqual(set(patterns), ignores.get_user_ignores())
87
87
 
88
88
        patterns = ['vim', '*.swp']
89
89
        ignores.set_user_ignores(patterns)
90
 
        self.assertEqual(patterns, ignores.get_user_ignores())
 
90
        self.assertEqual(set(patterns), ignores.get_user_ignores())
91
91
 
92
92
    def test_add(self):
93
93
        """Test that adding will not duplicate ignores"""
97
97
        patterns = ['foo', './bar', u'b\xe5z']
98
98
        added = ignores.add_unique_user_ignores(patterns)
99
99
        self.assertEqual(patterns, added)
100
 
        self.assertEqual(patterns, ignores.get_user_ignores())
 
100
        self.assertEqual(set(patterns), ignores.get_user_ignores())
101
101
 
102
102
    def test_add_unique(self):
103
103
        """Test that adding will not duplicate ignores"""
105
105
 
106
106
        added = ignores.add_unique_user_ignores(['xxx', './bar', 'xxx'])
107
107
        self.assertEqual(['xxx'], added)
108
 
        self.assertEqual(['foo', './bar', u'b\xe5z', 'xxx'],
 
108
        self.assertEqual(set(['foo', './bar', u'b\xe5z', 'xxx']),
109
109
                         ignores.get_user_ignores())
110
110
 
111
111