@@ -16,8 +16,7 @@ def mock_native():
1616 native_inst = MagicMock ()
1717 native_mod .NativeWebview .return_value = native_inst
1818
19- with patch ("pytron.webview.pytron_native" , native_mod ), \
20- patch ("threading.Thread" ):
19+ with patch ("pytron.webview.pytron_native" , native_mod ), patch ("threading.Thread" ):
2120 yield native_mod , native_inst
2221
2322
@@ -36,23 +35,22 @@ def webview_config():
3635def _make_webview (config , native_mod ):
3736 """Import inside function to avoid module-level side-effects."""
3837 from pytron .webview import Webview
38+
3939 return Webview (config )
4040
4141
4242def test_webview_init_error_handling (webview_config ):
4343 from pytron .webview import Webview
4444
4545 # 1. Binary missing
46- with patch ("pytron.webview.pytron_native" , None ), \
47- patch ("threading.Thread" ):
46+ with patch ("pytron.webview.pytron_native" , None ), patch ("threading.Thread" ):
4847 with pytest .raises (NativeEngineError ) as exc :
4948 Webview (webview_config )
5049 assert "binary" in str (exc .value )
5150
5251 # 2. WebView2 conflict 0x8007139F
5352 native_mod = MagicMock ()
54- with patch ("pytron.webview.pytron_native" , native_mod ), \
55- patch ("threading.Thread" ):
53+ with patch ("pytron.webview.pytron_native" , native_mod ), patch ("threading.Thread" ):
5654 with patch .object (
5755 native_mod ,
5856 "NativeWebview" ,
@@ -65,23 +63,25 @@ def test_webview_init_error_handling(webview_config):
6563
6664def test_webview_init_success (mock_native , webview_config ):
6765 from pytron .webview import Webview
66+
6867 native_mod , native_inst = mock_native
6968
7069 wv = Webview (webview_config )
7170
7271 native_mod .NativeWebview .assert_called_with (
7372 webview_config ["debug" ],
7473 "about:blank" ,
75- ANY , # root_path
74+ ANY , # root_path
7675 True , # resizable
77- False , # frameless
76+ False , # frameless
7877 None , # store_instance
7978 )
8079 assert wv ._start_url .endswith ("index.html" )
8180
8281
8382def test_webview_navigate (mock_native , webview_config ):
8483 from pytron .webview import Webview
84+
8585 native_mod , native_inst = mock_native
8686
8787 wv = Webview (webview_config )
@@ -93,6 +93,7 @@ def test_webview_navigate(mock_native, webview_config):
9393
9494def test_webview_set_title (mock_native , webview_config ):
9595 from pytron .webview import Webview
96+
9697 _ , native_inst = mock_native
9798
9899 wv = Webview (webview_config )
@@ -102,6 +103,7 @@ def test_webview_set_title(mock_native, webview_config):
102103
103104def test_webview_eval (mock_native , webview_config ):
104105 from pytron .webview import Webview
106+
105107 _ , native_inst = mock_native
106108
107109 wv = Webview (webview_config )
@@ -111,6 +113,7 @@ def test_webview_eval(mock_native, webview_config):
111113
112114def test_webview_bind (mock_native , webview_config ):
113115 from pytron .webview import Webview
116+
114117 _ , native_inst = mock_native
115118
116119 wv = Webview (webview_config )
@@ -120,6 +123,7 @@ def test_webview_bind(mock_native, webview_config):
120123
121124def test_webview_platform_methods (mock_native , webview_config ):
122125 from pytron .webview import Webview
126+
123127 _ , native_inst = mock_native
124128
125129 wv = Webview (webview_config )
@@ -139,6 +143,7 @@ def test_webview_platform_methods(mock_native, webview_config):
139143
140144def test_webview_close (mock_native , webview_config ):
141145 from pytron .webview import Webview
146+
142147 _ , native_inst = mock_native
143148
144149 wv = Webview (webview_config )
@@ -148,6 +153,7 @@ def test_webview_close(mock_native, webview_config):
148153
149154def test_webview_hide_show (mock_native , webview_config ):
150155 from pytron .webview import Webview
156+
151157 _ , native_inst = mock_native
152158
153159 cfg = {** webview_config , "start_hidden" : True }
@@ -168,10 +174,12 @@ def test_webview_windows_specific(webview_config):
168174
169175 cfg = {** webview_config , "hide_from_taskbar" : True }
170176
171- with patch ("pytron.webview.pytron_native" , native_mod ), \
172- patch ("threading.Thread" ), \
173- patch ("sys.platform" , "win32" ), \
174- patch ("pytron.platforms.windows.WindowsImplementation" ) as mock_win , \
175- patch .object (Webview , "hwnd" , new_callable = PropertyMock , return_value = 12345 ):
177+ with patch ("pytron.webview.pytron_native" , native_mod ), patch (
178+ "threading.Thread"
179+ ), patch ("sys.platform" , "win32" ), patch (
180+ "pytron.platforms.windows.WindowsImplementation"
181+ ) as mock_win , patch .object (
182+ Webview , "hwnd" , new_callable = PropertyMock , return_value = 12345
183+ ):
176184 wv = Webview (cfg )
177185 mock_win .return_value .set_utility_window .assert_called_with (12345 , True )
0 commit comments