Skip to content

Commit 28593f2

Browse files
committed
Merge branch 'main' into pytest-latest
2 parents b807a00 + 7ac5c95 commit 28593f2

File tree

4 files changed

+2
-20
lines changed

4 files changed

+2
-20
lines changed

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jsonschema==4.22.0
4444
jsonschema-specifications==2023.12.1
4545
libclang==18.1.1
4646
linkify-it-py==2.0.2
47-
litellm==1.44.8
47+
litellm
4848
loguru==0.7.2
4949
lxml==5.1.0
5050
markdown-it-py==3.0.0
@@ -72,7 +72,7 @@ nvidia-nccl-cu12==2.19.3
7272
nvidia-nvjitlink-cu12==12.4.99
7373
nvidia-nvtx-cu12==12.1.105
7474
ollama==0.3.3
75-
openai==1.50.2
75+
openai
7676
opt-einsum==3.3.0
7777
packaging==23.2
7878
platformdirs==4.1.0

test/app/search/test_search_backend.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
## These functions are used as monkey-patched implementations for the actual functions.
2222
## In Monkey-Patching, we temporarily replace the original function with a dummy function for testing purposes.
2323

24-
2524
# A fake implementation for find_python_files
2625
def fake_find_python_files(project_path: str):
2726
# Return a list with a single file in the project path.
@@ -59,18 +58,15 @@ def dummy_build_python_index(project_path: str):
5958
parsed_files,
6059
)
6160

62-
6361
# Dummy snippet generator.
6462
def dummy_get_code_snippets(file_name, start, end):
6563
return f"code from {file_name} lines {start}-{end}"
6664

67-
6865
class TestSearchBackend:
6966

7067
def test_build_index(self, monkeypatch):
7168
# Create an instance of SearchBackend with a dummy project_path.
7269
sb = SearchBackend(project_path="dummy_project")
73-
7470
# Clear the indices to start fresh.
7571
sb.class_index = {}
7672
sb.class_func_index = {}
@@ -96,7 +92,6 @@ def test_build_index(self, monkeypatch):
9692
def test_update_indices(self):
9793
# Create a SearchBackend instance with a dummy project path.
9894
sb = SearchBackend(project_path="dummy_project")
99-
10095
# Reset indexes to empty to start with a known state.
10196
sb.class_index = {}
10297
sb.class_func_index = {}
@@ -112,7 +107,6 @@ def test_update_indices(self):
112107
dummy_function_index = {"func": [("file2.py", (20, 30))]}
113108
dummy_class_relation_index = {"A": ["B", "C"]}
114109
dummy_parsed_files = ["file1.py", "file2.py"]
115-
116110
# Call _update_indices with dummy data.
117111
sb._update_indices(
118112
dummy_class_index,
@@ -121,7 +115,6 @@ def test_update_indices(self):
121115
dummy_class_relation_index,
122116
dummy_parsed_files,
123117
)
124-
125118
# Verify that the attributes have been updated as expected.
126119
assert sb.class_index == dummy_class_index
127120
assert sb.class_func_index == dummy_class_func_index
@@ -295,7 +288,6 @@ def test_search_func_in_all_classes(self, monkeypatch):
295288
assert res_a.class_name == "ClassA"
296289
assert res_a.func_name == "common"
297290
assert res_a.code == expected_code_a
298-
299291
# Verify result from ClassB.
300292
res_b = next(r for r in results if r.file_path == dummy_file2)
301293
expected_code_b = dummy_get_code_snippets(dummy_file2, 25, 35)
@@ -408,14 +400,12 @@ def top_func(self):
408400
assert res_top.class_name is None
409401
assert res_top.func_name == "top_func"
410402
assert res_top.code == expected_top
411-
412403
# Verify ClassX method result.
413404
res_classx = next(r for r in results if r.file_path == str(file2))
414405
expected_classx = dummy_get_code_snippets(str(file2), 2, 4)
415406
assert res_classx.class_name == "ClassX"
416407
assert res_classx.func_name == "top_func"
417408
assert res_classx.code == expected_classx
418-
419409
# Verify ClassY method result.
420410
res_classy = next(r for r in results if r.file_path == str(file3))
421411
expected_classy = dummy_get_code_snippets(str(file3), 2, 4)
@@ -425,15 +415,13 @@ def top_func(self):
425415

426416
def test_get_candidate_matched_py_files(self):
427417
sb = SearchBackend(project_path="dummy_project")
428-
429418
# Set up parsed_files with absolute paths (using various cases)
430419
sb.parsed_files = [
431420
"/abs/path/Foo.py",
432421
"/abs/path/bar.PY",
433422
"/abs/path/Baz.txt",
434423
"/abs/path/otherfoo.Py",
435424
]
436-
437425
# Test 1: Find files ending with "foo.py" (case-insensitive).
438426
# Expected candidates: "/abs/path/Foo.py" and "/abs/path/otherfoo.Py"
439427
candidates = sb._get_candidate_matched_py_files("foo.py")
@@ -464,7 +452,6 @@ def test_get_class_full_snippet_not_found(self):
464452

465453
# Call get_class_full_snippet with a class name that doesn't exist.
466454
result, search_res, flag = sb.get_class_full_snippet("NonExisting")
467-
468455
# Expect a message indicating that the class was not found, no search results, and flag False.
469456
expected_message = "Could not find class NonExisting in the codebase."
470457
assert result == expected_message
@@ -1540,7 +1527,6 @@ def test_get_file_content_found(self, monkeypatch):
15401527
sb.parsed_files = [dummy_path]
15411528
# Patch Path.read_text to return dummy content.
15421529
from pathlib import Path
1543-
15441530
monkeypatch.setattr(Path, "read_text", lambda self: "line1\nline2\nline3")
15451531
tool_output, results, flag = sb.get_file_content("existing.py")
15461532
expected = f"<file>existing.py</file> <code>line1\nline2\nline3</code>"
@@ -1683,12 +1669,10 @@ def test_get_bug_loc_snippets_new_with_method_and_class(
16831669
temp_file = temp_dir / "temp_file.py"
16841670
# Write multiple lines so that line indices 5 to 15 are valid.
16851671
temp_file.write_text("\n".join([f"line {i}" for i in range(1, 21)]))
1686-
16871672
# Use the absolute temporary directory as the project path.
16881673
sb = SearchBackend(project_path=str(temp_dir))
16891674
# Ensure parsed_files contains the temporary file.
16901675
sb.parsed_files = [str(temp_file)]
1691-
16921676
bug_loc = {
16931677
"file": "temp_file.py", # should match the end of the temp file path
16941678
"method": "do_work",

test/app/search/test_search_manage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ def dummy_generator(issue, sbfl, reproducer):
186186
# Define a dummy function with a self parameter.
187187
def dummy_func(self, arg1):
188188
return ("dummy result", None, True)
189-
190189
# Attach dummy_func as a bound method to the backend.
191190
sm.backend.dummy_func = dummy_func.__get__(sm.backend, type(sm.backend))
192191

test/app/search/test_search_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from app.search.search_utils import *
99

10-
1110
def test_is_test_file():
1211
# Setup: create a list of test file names
1312
test_files = [

0 commit comments

Comments
 (0)