36
36
' xx \n' # whitespace
38
self.assertEqual(['./rootdir',
38
self.assertEqual(set(['./rootdir',
46
46
def test_parse_empty(self):
47
47
ignored = ignores.parse_ignore_file(StringIO(''))
48
self.assertEqual([], ignored)
48
self.assertEqual(set([]), ignored)
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)
60
60
self.failUnlessExists(ignore_path)
61
61
f = open(ignore_path, 'rb')
63
63
entries = ignores.parse_ignore_file(f)
66
self.assertEqual(ignores.USER_DEFAULTS, user_ignores)
66
self.assertEqual(set(ignores.USER_DEFAULTS), entries)
68
68
def test_use_existing(self):
69
69
patterns = ['*.o', '*.py[co]', u'\xe5*']
70
70
ignores.set_user_ignores(patterns)
72
72
user_ignores = ignores.get_user_ignores()
73
self.assertEqual(patterns, user_ignores)
73
self.assertEqual(set(patterns), user_ignores)
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, '')
80
self.assertEqual([], ignores.get_user_ignores())
80
self.assertEqual(set([]), ignores.get_user_ignores())
82
82
def test_set(self):
83
83
patterns = ['*.py[co]', '*.py[oc]']
84
84
ignores.set_user_ignores(patterns)
86
self.assertEqual(patterns, ignores.get_user_ignores())
86
self.assertEqual(set(patterns), ignores.get_user_ignores())
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())
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())
102
102
def test_add_unique(self):
103
103
"""Test that adding will not duplicate ignores"""
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())