import pytest import chatbug.tool_helper as tool_helper from tests import helper def test_tool_function_decorator(): """ @tool """ # get length before adding tools start_len = len(tool_helper.tool_list) # add tools like it would be a decorator res = tool_helper.tool(helper.tool_dummy) assert res == helper.tool_dummy # decorator should return the function itself, so it is usable just in case. res = tool_helper.tool(helper.tool_dummy2) assert res == helper.tool_dummy2 # decorator should return the function itself, so it is usable just in case. # get length after adding tools end_len = len(tool_helper.tool_list) # remove the added ones again tool_helper.tool_list = tool_helper.tool_list[:-2] assert end_len == start_len + 2 assert len(tool_helper.tool_list) == start_len