File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 11import os
22import sys
3- from unittest .mock import MagicMock , patch
4- from fastapi .testclient import TestClient
5- from api .main import app
3+ from unittest .mock import patch
4+ from unittest .mock import MagicMock
65
7- # Add src to sys.path for imports
6+ # Add root to sys.path for imports
87sys .path .insert (
9- 0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , 'src' ))
8+ 0 ,
9+ os .path .abspath (
10+ os .path .join (
11+ os .path .dirname (__file__ ),
12+ '..' ,
13+ )
14+ ),
1015)
1116
12- # --- Patch before importing app ---
17+
1318mock_model = MagicMock ()
1419mock_model .predict_proba .return_value = [[0.3 , 0.7 ]]
1520
1621patcher = patch ('mlflow.sklearn.load_model' , return_value = mock_model )
1722patcher .start ()
23+
24+ from fastapi .testclient import TestClient # noqa: E402
25+ from api .main import app # noqa: E402
26+
1827client = TestClient (app )
1928
2029
You can’t perform that action at this time.
0 commit comments