Skip to content

Commit 92f713f

Browse files
committed
Mock webbrowser.open in device flow tests to prevent browser opening during test runs
1 parent 66af7db commit 92f713f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/test_auth.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class TestDeviceFlowAuth(unittest.TestCase):
179179
@mock.patch('chipflow.auth.time.sleep')
180180
@mock.patch('chipflow.auth.requests.post')
181181
@mock.patch('builtins.print')
182-
def test_device_flow_success(self, mock_print, mock_post, mock_sleep, mock_save):
182+
@mock.patch('webbrowser.open')
183+
def test_device_flow_success(self, mock_browser, mock_print, mock_post, mock_sleep, mock_save):
183184
"""Test successful device flow authentication"""
184185
# Mock init response
185186
init_response = mock.Mock()
@@ -207,7 +208,8 @@ def test_device_flow_success(self, mock_print, mock_post, mock_sleep, mock_save)
207208
@mock.patch('chipflow.auth.time.sleep')
208209
@mock.patch('chipflow.auth.requests.post')
209210
@mock.patch('builtins.print')
210-
def test_device_flow_pending_then_success(self, mock_print, mock_post, mock_sleep):
211+
@mock.patch('webbrowser.open')
212+
def test_device_flow_pending_then_success(self, mock_browser, mock_print, mock_post, mock_sleep):
211213
"""Test device flow with pending state then success"""
212214
# Mock init response
213215
init_response = mock.Mock()
@@ -241,7 +243,8 @@ def test_device_flow_pending_then_success(self, mock_print, mock_post, mock_slee
241243
@mock.patch('chipflow.auth.time.sleep')
242244
@mock.patch('chipflow.auth.requests.post')
243245
@mock.patch('builtins.print')
244-
def test_device_flow_timeout(self, mock_print, mock_post, mock_sleep):
246+
@mock.patch('webbrowser.open')
247+
def test_device_flow_timeout(self, mock_browser, mock_print, mock_post, mock_sleep):
245248
"""Test device flow timeout"""
246249
# Mock init response
247250
init_response = mock.Mock()

0 commit comments

Comments
 (0)