mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
aider: Replaced string with bytes object in test_check_for_ctags_success to fix 'decode' method issue.
# Context: USER: running test_check_for_ctags_success i get: tests/test_repomap.py 'str' object has no attribute 'decode' ASSISTANT: It seems like the issue is with the `decode` method being called on a string object. I'll fix this issue for you. Here's the change you need to make in the `tests/test_repomap.py` file: ```python tests/test_repomap.py <<<<<<< ORIGINAL mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout='''{ "_type": "tag", "name": "status", "path": "aider/main.py", "pattern": "/^ status = main()$/", "kind": "variable" }''') ======= mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout=b'''{ "_type": "tag", "name": "status", "path": "aider/main.py", "pattern": "/^ status = main()$/", "kind": "variable" }''') >>>>>>> UPDATED ``` This change replaces the string with a bytes object, so the `decode` method can be called without any issues.
This commit is contained in:
parent
f5de27ccdd
commit
346eb7a834
2 changed files with 4 additions and 2 deletions
|
@ -141,6 +141,7 @@ class RepoMap:
|
||||||
cmd = self.ctags_cmd + [filename]
|
cmd = self.ctags_cmd + [filename]
|
||||||
output = subprocess.check_output(cmd).decode("utf-8")
|
output = subprocess.check_output(cmd).decode("utf-8")
|
||||||
output = output.splitlines()
|
output = output.splitlines()
|
||||||
|
print('output', output)
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
if not output:
|
if not output:
|
||||||
|
@ -175,7 +176,8 @@ class RepoMap:
|
||||||
with open(hello_py, "w") as f:
|
with open(hello_py, "w") as f:
|
||||||
f.write("def hello():\n print('Hello, world!')\n")
|
f.write("def hello():\n print('Hello, world!')\n")
|
||||||
self.get_tags(hello_py)
|
self.get_tags(hello_py)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ def my_function(arg1, arg2):
|
||||||
|
|
||||||
def test_check_for_ctags_success(self):
|
def test_check_for_ctags_success(self):
|
||||||
with patch("subprocess.run") as mock_run:
|
with patch("subprocess.run") as mock_run:
|
||||||
mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout='''{
|
mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout=b'''{
|
||||||
"_type": "tag",
|
"_type": "tag",
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"path": "aider/main.py",
|
"path": "aider/main.py",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue