@@ -86,6 +86,7 @@ async def test_transitive_search_golang_5():
8686 assert path_found is False
8787 assert len (list_path ) is 1
8888
89+
8990# Test fix of https://issues.redhat.com/browse/APPENG-3435
9091@pytest .mark .asyncio
9192async def test_transitive_search_golang_6 ():
@@ -125,6 +126,7 @@ async def get_transitive_code_runner_function():
125126 async for function in transitive_code_search .gen :
126127 return function .single_fn
127128
129+
128130python_dependency_tree_mock_output = (
129131 'deptree==0.0.12 # deptree\n '
130132 ' importlib-metadata==8.7.0 # importlib-metadata\n '
@@ -142,6 +144,7 @@ async def get_transitive_code_runner_function():
142144 ' mock-package==1.1.1'
143145)
144146
147+
145148def mock_file_open (* args , ** kwargs ):
146149 file_path = args [0 ] if args else kwargs .get ('file' , '' )
147150 mock_file = MagicMock ()
@@ -174,19 +177,21 @@ def mock_file_open(*args, **kwargs):
174177 "search_query" : "werkzeug,formparser.MultiPartParser.parse" ,
175178 "expected_path_found" : False ,
176179 "expected_list_length" : 0 ,
177- "mock_documents" : [python_script_example , python_init_function_example , python_full_document_example , python_parse_function_example ]
180+ "mock_documents" : [python_script_example , python_init_function_example , python_full_document_example ,
181+ python_parse_function_example ]
178182 },
179183 {
180184 "name" : "python_3" ,
181185 "search_query" : "mock_package,mock_function_in_use" ,
182186 "expected_path_found" : True ,
183187 "expected_list_length" : 3 ,
184- "mock_documents" : [python_script_example , python_init_function_example , python_full_document_example , python_parse_function_example , python_mock_function_in_use , python_mock_file ]
188+ "mock_documents" : [python_script_example , python_init_function_example , python_full_document_example ,
189+ python_parse_function_example , python_mock_function_in_use , python_mock_file ]
185190 }
186191])
187192@patch ('vuln_analysis.utils.dep_tree.run_command' , return_value = python_dependency_tree_mock_output )
188193@patch ('builtins.open' , side_effect = mock_file_open )
189- async def test_transitive_search_python_parameterized (mock_open , mock_run_command ,test_case ):
194+ async def test_transitive_search_python_parameterized (mock_open , mock_run_command , test_case ):
190195 """Parameterized test that runs all existing test cases with their respective configurations."""
191196 transitive_code_search_runner_coroutine = await get_transitive_code_runner_function ()
192197 logging .basicConfig (level = logging .DEBUG )
@@ -199,7 +204,7 @@ async def test_transitive_search_python_parameterized(mock_open, mock_run_comman
199204 )
200205
201206 with patch ('vuln_analysis.utils.document_embedding.retrieve_from_cache' ,
202- return_value = (test_case ["mock_documents" ], True )):
207+ return_value = (test_case ["mock_documents" ], True )):
203208 result = await transitive_code_search_runner_coroutine (test_case ["search_query" ])
204209
205210 (path_found , list_path ) = result
@@ -210,6 +215,7 @@ async def test_transitive_search_python_parameterized(mock_open, mock_run_comman
210215 assert path_found == test_case ["expected_path_found" ]
211216 assert len (list_path ) == test_case ["expected_list_length" ]
212217
218+
213219@pytest .mark .asyncio
214220async def test_python_transitive_search ():
215221 """Test that runs with a real repository"""
@@ -229,5 +235,5 @@ async def test_python_transitive_search():
229235 print (f"DEBUG: path_found = { path_found } " )
230236 print (f"DEBUG: list_path = { list_path } " )
231237 print (f"DEBUG: len(list_path) = { len (list_path )} " )
232- assert path_found == True
233- assert len (list_path ) == 2
238+ assert path_found is True
239+ assert len (list_path ) == 2
0 commit comments