diff --git a/pyproject.toml b/pyproject.toml index 0ce774d9a..f2ff1814d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -330,6 +330,7 @@ ignore = [ "test/plugins/test_ftintitle.py" = ["E501"] "test/test_util.py" = ["E501"] "test/ui/test_field_diff.py" = ["E501"] +"test/ui/test_ui_init.py" = ["PT"] "test/util/test_id_extractors.py" = ["E501"] "test/**" = ["RUF001"] # we use Unicode characters in tests diff --git a/test/ui/test_ui_init.py b/test/ui/test_ui_init.py index 2209f32c4..1bbb0bb61 100644 --- a/test/ui/test_ui_init.py +++ b/test/ui/test_ui_init.py @@ -129,15 +129,19 @@ class DatabaseErrorTest(BeetsTestCase): def test_database_error_with_unable_to_open(self): """Test error message when database fails with 'unable to open' error.""" test_config = deepcopy(config) - test_config["library"] = os.path.join(self.temp_dir, b"test.db") - + test_config["library"] = os.path.join(self.temp_dir, "test.db") + # Mock Library to raise OperationalError with "unable to open" with mock.patch.object( - library, 'Library', side_effect=sqlite3.OperationalError("unable to open database file") + library, + "Library", + side_effect=sqlite3.OperationalError( + "unable to open database file" + ), ): with self.assertRaises(ui.UserError) as cm: ui._open_library(test_config) - + error_message = str(cm.exception) # Should mention directory permissions self.assertIn("directory", error_message.lower()) @@ -146,15 +150,17 @@ class DatabaseErrorTest(BeetsTestCase): def test_database_error_fallback(self): """Test fallback error message for other database errors.""" test_config = deepcopy(config) - test_config["library"] = os.path.join(self.temp_dir, b"test.db") - + test_config["library"] = os.path.join(self.temp_dir, "test.db") + # Mock Library to raise a different OperationalError with mock.patch.object( - library, 'Library', side_effect=sqlite3.OperationalError("disk I/O error") + library, + "Library", + side_effect=sqlite3.OperationalError("disk I/O error"), ): with self.assertRaises(ui.UserError) as cm: ui._open_library(test_config) - + error_message = str(cm.exception) # Should contain the error but not the directory writable message self.assertIn("could not be opened", error_message)