Skip to content

Commit 850fba2

Browse files
committed
style: fix import sorting in test_stdio.py
1 parent c83b5ed commit 850fba2

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

tests/client/test_stdio.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ def mock_import(name, globals=None, locals=None, fromlist=(), level=0):
733733
with patch("builtins.__import__", side_effect=mock_import):
734734
# Re-import to get fresh function that will use the mocked import
735735
import importlib
736+
736737
import mcp.client.stdio
737738

738739
importlib.reload(mcp.client.stdio)
@@ -752,6 +753,7 @@ def mock_import2(name, globals=None, locals=None, fromlist=(), level=0):
752753

753754
with patch("builtins.__import__", side_effect=mock_import2):
754755
import importlib
756+
755757
import mcp.client.stdio
756758

757759
importlib.reload(mcp.client.stdio)
@@ -772,28 +774,29 @@ def test_print_stderr_jupyter():
772774
# We need to mock the import inside the function since IPython may not be installed
773775
mock_html_class = MagicMock()
774776
mock_display_func = MagicMock()
775-
777+
776778
# Create a mock module structure that matches "from IPython.display import HTML, display"
777779
mock_display_module = MagicMock()
778780
mock_display_module.HTML = mock_html_class
779781
mock_display_module.display = mock_display_func
780-
782+
781783
# Create mock IPython module with display submodule
782784
mock_ipython_module = MagicMock()
783785
mock_ipython_module.display = mock_display_module
784-
786+
785787
original_import = __import__
786-
788+
787789
def mock_import(name, globals=None, locals=None, fromlist=(), level=0):
788790
if name == "IPython.display":
789791
return mock_display_module
790792
if name == "IPython":
791793
return mock_ipython_module
792794
# For other imports, use real import
793795
return original_import(name, globals, locals, fromlist, level)
794-
795-
with patch("mcp.client.stdio._is_jupyter_notebook", return_value=True), patch(
796-
"builtins.__import__", side_effect=mock_import
796+
797+
with (
798+
patch("mcp.client.stdio._is_jupyter_notebook", return_value=True),
799+
patch("builtins.__import__", side_effect=mock_import),
797800
):
798801
_print_stderr("test error message", sys.stderr)
799802

@@ -805,22 +808,22 @@ def mock_import(name, globals=None, locals=None, fromlist=(), level=0):
805808
def test_print_stderr_jupyter_fallback():
806809
"""Test stderr printing falls back to regular print if IPython display fails."""
807810
stderr_capture = io.StringIO()
808-
811+
809812
# Mock IPython import to raise exception on display
810813
mock_html_class = MagicMock()
811814
mock_display_func = MagicMock(side_effect=Exception("Display failed"))
812-
815+
813816
# Create a mock module structure that matches "from IPython.display import HTML, display"
814817
mock_display_module = MagicMock()
815818
mock_display_module.HTML = mock_html_class
816819
mock_display_module.display = mock_display_func
817-
820+
818821
# Create mock IPython module with display submodule
819822
mock_ipython_module = MagicMock()
820823
mock_ipython_module.display = mock_display_module
821-
824+
822825
original_import = __import__
823-
826+
824827
def mock_import(name, globals=None, locals=None, fromlist=(), level=0):
825828
if name == "IPython.display":
826829
return mock_display_module
@@ -829,8 +832,9 @@ def mock_import(name, globals=None, locals=None, fromlist=(), level=0):
829832
# For other imports, use real import
830833
return original_import(name, globals, locals, fromlist, level)
831834

832-
with patch("mcp.client.stdio._is_jupyter_notebook", return_value=True), patch(
833-
"builtins.__import__", side_effect=mock_import
835+
with (
836+
patch("mcp.client.stdio._is_jupyter_notebook", return_value=True),
837+
patch("builtins.__import__", side_effect=mock_import),
834838
):
835839
_print_stderr("test error message", stderr_capture)
836840

0 commit comments

Comments
 (0)