mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 22:44:21 +01:00
* move remove_color_codes to utils and add tests * Fix for ai_settings goals loaded as list(dict) Some ai_settings formats can cause goals to load as list(dict) not list(str) Refactor code in utils.py to explicitly convert input type to string in remove_color_codes() function. - Updated remove_color_codes function to convert input argument to string type explicitly to avoid unexpected type errors. - Test case added to check conversion of dict to string in remove_color_codes function. * Update tests/test_utils.py Co-authored-by: James Collins <collijk@uw.edu> * move remove_color_codes fn and tests to proper files --------- Co-authored-by: Luke Kyohere <lkyohere@mfsafrica.com> Co-authored-by: James Collins <collijk@uw.edu>
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
import pytest
|
|
|
|
from autogpt.logs import remove_color_codes
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"raw_text, clean_text",
|
|
[
|
|
(
|
|
"COMMAND = \x1b[36mbrowse_website\x1b[0m ARGUMENTS = \x1b[36m{'url': 'https://www.google.com', 'question': 'What is the capital of France?'}\x1b[0m",
|
|
"COMMAND = browse_website ARGUMENTS = {'url': 'https://www.google.com', 'question': 'What is the capital of France?'}",
|
|
),
|
|
(
|
|
"{'Schaue dir meine Projekte auf github () an, als auch meine Webseiten': 'https://github.com/Significant-Gravitas/Auto-GPT, https://discord.gg/autogpt und https://twitter.com/SigGravitas'}",
|
|
"{'Schaue dir meine Projekte auf github () an, als auch meine Webseiten': 'https://github.com/Significant-Gravitas/Auto-GPT, https://discord.gg/autogpt und https://twitter.com/SigGravitas'}",
|
|
),
|
|
("", ""),
|
|
("hello", "hello"),
|
|
("hello\x1B[31m world", "hello world"),
|
|
("\x1B[36mHello,\x1B[32m World!", "Hello, World!"),
|
|
(
|
|
"\x1B[1m\x1B[31mError:\x1B[0m\x1B[31m file not found",
|
|
"Error: file not found",
|
|
),
|
|
],
|
|
)
|
|
def test_remove_color_codes(raw_text, clean_text):
|
|
assert remove_color_codes(raw_text) == clean_text
|