mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 15:22:42 +01:00
Added a Patch decorator for the os.path.samefile function to repair some previously failed test cases.
This commit is contained in:
parent
636f0af8b2
commit
58ddecf7af
1 changed files with 20 additions and 11 deletions
|
|
@ -376,12 +376,17 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin):
|
|||
self.i.store()
|
||||
self.lib.add_album([self.i])
|
||||
|
||||
self.patcher = patch('beets.library.os.path.exists')
|
||||
self.patcher.start().return_value = True
|
||||
self.patcher_exists = patch('beets.library.os.path.exists')
|
||||
self.patcher_exists.start().return_value = True
|
||||
|
||||
self.patcher_samefile = patch('beets.library.os.path.samefile')
|
||||
self.patcher_samefile.start().return_value = True
|
||||
|
||||
def tearDown(self):
|
||||
super(PathQueryTest, self).tearDown()
|
||||
self.patcher.stop()
|
||||
|
||||
self.patcher_samefile.stop()
|
||||
self.patcher_exists.stop()
|
||||
|
||||
def test_path_exact_match(self):
|
||||
q = 'path:/a/b/c.mp3'
|
||||
|
|
@ -504,13 +509,17 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin):
|
|||
self.assert_items_matched(results, ['path item', 'caps path'])
|
||||
|
||||
# test platform-aware default sensitivity
|
||||
with _common.system_mock('Darwin'):
|
||||
q = makeq()
|
||||
self.assertEqual(q.case_sensitive, True)
|
||||
self.patcher_exists.stop()
|
||||
try:
|
||||
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)
|
||||
with _common.system_mock('Windows'):
|
||||
q = makeq()
|
||||
self.assertEqual(q.case_sensitive, False)
|
||||
finally:
|
||||
self.patcher_exists.start()
|
||||
|
||||
@patch('beets.library.os')
|
||||
def test_path_sep_detection(self, mock_os):
|
||||
|
|
@ -526,7 +535,7 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin):
|
|||
|
||||
def test_path_detection(self):
|
||||
# cover existence test
|
||||
self.patcher.stop()
|
||||
self.patcher_exists.stop()
|
||||
is_path = beets.library.PathQuery.is_path_query
|
||||
|
||||
try:
|
||||
|
|
@ -546,7 +555,7 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin):
|
|||
finally:
|
||||
os.chdir(cur_dir)
|
||||
finally:
|
||||
self.patcher.start()
|
||||
self.patcher_exists.start()
|
||||
|
||||
|
||||
class IntQueryTest(unittest.TestCase, TestHelper):
|
||||
|
|
|
|||
Loading…
Reference in a new issue