diff --git a/test/test_query.py b/test/test_query.py index 3c6d6f70a..13f40482b 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -603,40 +603,7 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin): results = self.lib.items(makeq(case_sensitive=False)) self.assert_items_matched(results, ['path item', 'caps path']) - # Check for correct case sensitivity selection (this check - # only works on non-Windows OSes). - with _common.system_mock('Darwin'): - # exists = True and samefile = True => Case insensitive - q = makeq() - self.assertEqual(q.case_sensitive, False) - # exists = True and samefile = False => Case sensitive - self.patcher_samefile.stop() - self.patcher_samefile.start().return_value = False - try: - q = makeq() - self.assertEqual(q.case_sensitive, True) - finally: - self.patcher_samefile.stop() - self.patcher_samefile.start().return_value = True - - # Test platform-aware default sensitivity when the library path - # does not exist. For the duration of this check, we change the - # `os.path.exists` mock to return False. - self.patcher_exists.stop() - self.patcher_exists.start().return_value = False - 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) - finally: - # Restore the `os.path.exists` mock to its original state. - self.patcher_exists.stop() - self.patcher_exists.start().return_value = True @patch('beets.library.os') def test_path_sep_detection(self, mock_os): diff --git a/test/test_util.py b/test/test_util.py index 14ac7f2b2..8c16243a5 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -14,10 +14,11 @@ """Tests for base utils from the beets.util package. """ -import sys -import re import os +import platform +import re import subprocess +import sys import unittest from unittest.mock import patch, Mock @@ -122,6 +123,28 @@ class UtilTest(unittest.TestCase): self.assertEqual(exc_context.exception.returncode, 1) self.assertEqual(exc_context.exception.cmd, 'taga \xc3\xa9') + def test_case_sensitive_default(self): + path = util.bytestring_path(util.normpath( + "/this/path/does/not/exist", + )) + + self.assertEqual( + util.case_sensitive(path), + platform.system() != 'Windows', + ) + + @unittest.skipIf(sys.platform == 'win32', 'fs is not case sensitive') + def test_case_sensitive_detects_sensitive(self): + # FIXME: Add tests for more code paths of case_sensitive() + # when the filesystem on the test runner is not case sensitive + pass + + @unittest.skipIf(sys.platform != 'win32', 'fs is case sensitive') + def test_case_sensitive_detects_insensitive(self): + # FIXME: Add tests for more code paths of case_sensitive() + # when the filesystem on the test runner is case sensitive + pass + class PathConversionTest(_common.TestCase): def test_syspath_windows_format(self):