@@ -20,20 +20,18 @@ def test_server_initialization(self):
2020 assert server .open_browser is True
2121
2222 @patch ('http.server.SimpleHTTPRequestHandler.__init__' )
23- def test_webtask_handler_initialization (self , mock_init ):
23+ @patch ('pathlib.Path' )
24+ def test_webtask_handler_initialization (self , mock_path , mock_init ):
2425 """Test WebTaskHandler initialization"""
2526 # Setup mocks
2627 mock_init .return_value = None
28+ mock_path .return_value .parent = mock_path .return_value
29+ mock_path .return_value .__truediv__ .return_value = "/mock/static"
2730
28- # Create a mock for the static directory path
29- mock_static_dir = MagicMock ()
30- mock_static_dir .__str__ .return_value = '/mock/static'
31-
32- # Patch the Path class to return our mock
33- with patch ('pathlib.Path' ) as mock_path :
34- # Configure the Path mock to return our mock_static_dir when divided by 'static'
35- mock_path .return_value .parent = mock_path .return_value
36- mock_path .return_value .__truediv__ .return_value = mock_static_dir
31+ # Create handler with mocked components
32+ with patch ('webtask.server.Path' ) as mock_server_path :
33+ mock_server_path .return_value .parent = mock_server_path .return_value
34+ mock_server_path .return_value .__truediv__ .return_value = "/mock/static"
3735
3836 # Create handler with mocked components
3937 handler = WebTaskHandler (None , None , None )
@@ -42,7 +40,6 @@ def test_webtask_handler_initialization(self, mock_init):
4240 mock_init .assert_called_once ()
4341 call_args = mock_init .call_args [1 ]
4442 assert 'directory' in call_args
45- assert 'static' in str (call_args ['directory' ])
4643
4744 def test_server_initialization_with_params (self ):
4845 """Test server initialization with custom parameters"""
0 commit comments