Skip to content

Commit 8b31095

Browse files
committed
Avoid logging to stale ITestOutputHelper in fixture disposal
1 parent 3f6b34b commit 8b31095

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/ModelContextProtocol.Tests/SseServerIntegrationTestFixture.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
1111
{
1212
private readonly Task _serverTask;
1313
private readonly CancellationTokenSource _stopCts = new();
14-
private DelegatingTestOutputHelper _delegatingTestOutputHelper = new();
1514

16-
private ILoggerFactory _redirectingLoggerFactory;
15+
private readonly DelegatingTestOutputHelper _delegatingTestOutputHelper = new();
16+
private readonly ILoggerFactory _redirectingLoggerFactory;
1717

1818
public McpClientOptions DefaultOptions { get; }
1919
public McpServerConfig DefaultConfig { get; }
@@ -50,7 +50,7 @@ public void Initialize(ITestOutputHelper output)
5050

5151
public async ValueTask DisposeAsync()
5252
{
53-
_redirectingLoggerFactory.Dispose();
53+
_delegatingTestOutputHelper.CurrentTestOutputHelper = null;
5454
_stopCts.Cancel();
5555
try
5656
{
@@ -59,6 +59,7 @@ public async ValueTask DisposeAsync()
5959
catch (OperationCanceledException)
6060
{
6161
}
62+
_redirectingLoggerFactory.Dispose();
6263
_stopCts.Dispose();
6364
}
6465

0 commit comments

Comments
 (0)