Improved the case sensitivity detection test.

This commit is contained in:
Malte Ried 2015-09-07 12:28:19 +02:00
parent 58ddecf7af
commit 42f99999f2

View file

@ -508,18 +508,36 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin):
results = self.lib.items(makeq(case_sensitive=False)) results = self.lib.items(makeq(case_sensitive=False))
self.assert_items_matched(results, ['path item', 'caps path']) self.assert_items_matched(results, ['path item', 'caps path'])
# test platform-aware default sensitivity # Check for correct case sensitivity selection (this check
self.patcher_exists.stop() # only works for non-windows os)
try: with _common.system_mock('Darwin'):
with _common.system_mock('Darwin'): # exists = True and samefile = True => Case insensitive
q = makeq() q = makeq()
self.assertEqual(q.case_sensitive, True) self.assertEqual(q.case_sensitive, False)
with _common.system_mock('Windows'): self.patcher_samefile.stop()
q = makeq() self.patcher_samefile.start().return_value = False
self.assertEqual(q.case_sensitive, False)
finally: # exists = True and samefile = False => Case sensitive
self.patcher_exists.start() q = makeq()
self.assertEqual(q.case_sensitive, True)
self.patcher_samefile.stop()
self.patcher_samefile.start().return_value = True
# test platform-aware default sensitivity when the library
# path does not exist (exist = False)
self.patcher_exists.stop()
self.patcher_exists.start().return_value = False
with _common.system_mock('Darwin'):
q = makeq()
self.assertEqual(q.case_sensitive, True)
with _common.system_mock('Windows'):
q = makeq()
self.assertEqual(q.case_sensitive, False)
self.patcher_exists.stop()
self.patcher_exists.start().return_value = True
@patch('beets.library.os') @patch('beets.library.os')
def test_path_sep_detection(self, mock_os): def test_path_sep_detection(self, mock_os):