Remove LanguageServerLogger

Resolves #745
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2025-11-20 21:33:37 +01:00
1 parent 4702fbe1ea
commit 82d495b2a6
45 files changed
+659 -1120

No files matched your search

+18 -12
View File
@@ -5,6 +5,7 @@ from typing import cast
from unittest.mock import Mock, patch
import pytest
from sensai.util import logging
from solidlsp import SolidLanguageServer
from solidlsp.language_servers.csharp_language_server import (
@@ -247,8 +248,6 @@ class TestCSharpSolutionProjectOpening:
solution_file = temp_path / "TestSolution.sln"
solution_file.touch()
# Mock logger to capture log messages
mock_logger = Mock()
mock_config = Mock(spec=LanguageServerConfig)
mock_config.ignored_paths = []
@@ -256,10 +255,15 @@ class TestCSharpSolutionProjectOpening:
mock_settings = Mock(spec=SolidLSPSettings)
mock_settings.ls_resources_dir = "/tmp/test_ls_resources"
mock_settings.project_data_relative_path = "project_data"
CSharpLanguageServer(mock_config, mock_logger, str(temp_path), mock_settings)
# Verify that logger was called with solution file discovery
mock_logger.log.assert_any_call(f"Found solution/project file: {solution_file}", 20) # logging.INFO
with logging.SuspendedLoggersContext():
logging.getLogger().setLevel(logging.DEBUG)
with logging.MemoryLoggerContext() as mem_log:
CSharpLanguageServer(mock_config, str(temp_path), mock_settings)
# Verify that logger was called with solution file discovery
expected_log_msg = f"Found solution/project file: {solution_file}"
assert expected_log_msg in mem_log.get_log()
@patch("solidlsp.language_servers.csharp_language_server.CSharpLanguageServer._ensure_server_installed")
@patch("solidlsp.language_servers.csharp_language_server.CSharpLanguageServer._start_server")
@@ -273,20 +277,22 @@ class TestCSharpSolutionProjectOpening:
temp_path = Path(temp_dir)
# Mock logger to capture log messages
mock_logger = Mock()
mock_config = Mock(spec=LanguageServerConfig)
mock_config.ignored_paths = []
# Create CSharpLanguageServer instance
mock_settings = Mock(spec=SolidLSPSettings)
mock_settings.ls_resources_dir = "/tmp/test_ls_resources"
mock_settings.project_data_relative_path = "project_data"
CSharpLanguageServer(mock_config, mock_logger, str(temp_path), mock_settings)
# Verify that logger was called with warning about no solution/project files
mock_logger.log.assert_any_call(
"No .sln or .csproj file found, language server will attempt auto-discovery", 30 # logging.WARNING
)
# Create CSharpLanguageServer instance
with logging.SuspendedLoggersContext():
logging.getLogger().setLevel(logging.DEBUG)
with logging.MemoryLoggerContext() as mem_log:
CSharpLanguageServer(mock_config, str(temp_path), mock_settings)
# Verify that logger was called with warning about no solution/project files
expected_log_msg = "No .sln or .csproj file found, language server will attempt auto-discovery"
assert expected_log_msg in mem_log.get_log()
def test_solution_and_project_opening_with_real_test_repo(self):
"""Test solution and project opening with the actual C# test repository."""