1
1
from pathlib import Path
2
2
from typing import Callable
3
- from unittest .mock import patch
3
+ from unittest .mock import Mock , patch
4
4
5
5
import pytest
6
6
import yaml
@@ -203,7 +203,9 @@ def test_pass_detect_cli(
203
203
test_data : dict ,
204
204
detect_cli : Callable ,
205
205
) -> None :
206
- with patch ("OTVision.detect" ) as mock_detect :
206
+ with patch ("detect.OTVisionDetect" ) as mock_detect :
207
+ mock_detect_instance = Mock ()
208
+ mock_detect .return_value = mock_detect_instance
207
209
command = [
208
210
* test_data ["paths" ][PASSED ].split (),
209
211
* test_data ["weights" ][PASSED ].split (),
@@ -223,6 +225,7 @@ def test_pass_detect_cli(
223
225
expected_config = create_expected_config_from_test_data (test_data )
224
226
225
227
mock_detect .assert_called_once_with (expected_config )
228
+ mock_detect_instance .start .assert_called_once ()
226
229
227
230
@pytest .mark .parametrize (argnames = "test_fail_data" , argvalues = TEST_FAIL_DATA )
228
231
def test_fail_wrong_types_passed_to_detect_cli (
@@ -232,7 +235,7 @@ def test_fail_wrong_types_passed_to_detect_cli(
232
235
test_fail_data : dict ,
233
236
) -> None :
234
237
235
- with patch ("OTVision. detect" ):
238
+ with patch ("detect.OTVisionDetect " ):
236
239
with pytest .raises (SystemExit ) as e :
237
240
command = [* test_fail_data [PASSED ].split ()]
238
241
detect_cli (argv = list (filter (None , command )))
@@ -244,13 +247,13 @@ def test_fail_wrong_types_passed_to_detect_cli(
244
247
def test_fail_not_existing_path_passed_to_detect_cli (
245
248
self , detect_cli : Callable , passed : str
246
249
) -> None :
247
- with patch ("OTVision. detect" ):
250
+ with patch ("detect.OTVisionDetect " ):
248
251
with pytest .raises (FileNotFoundError ):
249
252
command = required_arguments .split () + [* passed .split ()]
250
253
detect_cli (argv = list (filter (None , command )))
251
254
252
255
def test_fail_no_paths_passed_to_detect_cli (self , detect_cli : Callable ) -> None :
253
- with patch ("OTVision. detect" ):
256
+ with patch ("detect.OTVisionDetect " ):
254
257
error_msg = (
255
258
"No paths have been passed as command line args."
256
259
+ "No paths have been defined in the user config."
0 commit comments