Skip to content

A programming framework for agentic AI

Let run tests directly via `python test_xyz.py`, fix for `conftest` import via `sys.path.append` (#1144)

Maxim Saplin3f343654bd40
diff --git a/notebook/oai_client_cost.ipynb b/notebook/oai_client_cost.ipynb
index 857ee327a..e4b356793 100644
--- a/notebook/oai_client_cost.ipynb
+++ b/notebook/oai_client_cost.ipynb
@@ -300,7 +300,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.9.18"
+ "version": "3.11.6"
}
},
"nbformat": 4,
diff --git a/test/agentchat/contrib/test_agent_builder.py b/test/agentchat/contrib/test_agent_builder.py
index 7380d6e62..de999f8b2 100644
--- a/test/agentchat/contrib/test_agent_builder.py
+++ b/test/agentchat/contrib/test_agent_builder.py
@@ -5,7 +5,9 @@ import sys
from packaging.requirements import Requirement
from autogen.agentchat.contrib.agent_builder import AgentBuilder
from autogen import UserProxyAgent
-from conftest import skip_openai
+
+sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
+from conftest import skip_openai # noqa: E402
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402
diff --git a/test/agentchat/contrib/test_compressible_agent.py b/test/agentchat/contrib/test_compressible_agent.py
index 298fd01e9..9c5145a8d 100644
--- a/test/agentchat/contrib/test_compressible_agent.py
+++ b/test/agentchat/contrib/test_compressible_agent.py
@@ -2,9 +2,11 @@ import pytest
import sys
import autogen
import os
-from conftest import skip_openai
from autogen.agentchat.contrib.compressible_agent import CompressibleAgent
+sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
+from conftest import skip_openai # noqa: E402
+
here = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
@@ -12,7 +14,6 @@ from test_assistant_agent import OAI_CONFIG_LIST, KEY_LOC # noqa: E402
try:
import openai
-
except ImportError:
skip = True
else:
diff --git a/test/agentchat/contrib/test_gpt_assistant.py b/test/agentchat/contrib/test_gpt_assistant.py
index 0a7e92e8c..b4674b7c0 100644
--- a/test/agentchat/contrib/test_gpt_assistant.py
+++ b/test/agentchat/contrib/test_gpt_assistant.py
@@ -3,7 +3,9 @@ import os
import sys
import autogen
from autogen import OpenAIWrapper
-from conftest import skip_openai
+
+sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
+from conftest import skip_openai # noqa: E402
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402
diff --git a/test/agentchat/contrib/test_teachable_agent.py b/test/agentchat/contrib/test_teachable_agent.py
index b8156296b..0d8285f1d 100644
--- a/test/agentchat/contrib/test_teachable_agent.py
+++ b/test/agentchat/contrib/test_teachable_agent.py
@@ -2,7 +2,9 @@ import pytest
import os
import sys
from autogen import ConversableAgent, config_list_from_json
-from conftest import skip_openai
+
+sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
+from conftest import skip_openai # noqa: E402
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from test_assistant_agent import OAI_CONFIG_LIST, KEY_LOC # noqa: E402
diff --git a/test/agentchat/test_assistant_agent.py b/test/agentchat/test_assistant_agent.py
index b05a1b77b..0bd227851 100644
--- a/test/agentchat/test_assistant_agent.py
+++ b/test/agentchat/test_assistant_agent.py
@@ -2,9 +2,11 @@ import os
import sys
import pytest
import autogen
-from conftest import skip_openai
from autogen.agentchat import AssistantAgent, UserProxyAgent
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
+
try:
from openai import OpenAI
except ImportError:
diff --git a/test/agentchat/test_async.py b/test/agentchat/test_async.py
index d31f50c0c..496b73f7b 100644
--- a/test/agentchat/test_async.py
+++ b/test/agentchat/test_async.py
@@ -1,8 +1,12 @@
import pytest
import asyncio
import autogen
-from conftest import skip_openai
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST
+import sys
+import os
+
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
try:
from openai import OpenAI
diff --git a/test/agentchat/test_async_get_human_input.py b/test/agentchat/test_async_get_human_input.py
index f9de9f1c2..1285696c0 100644
--- a/test/agentchat/test_async_get_human_input.py
+++ b/test/agentchat/test_async_get_human_input.py
@@ -1,8 +1,12 @@
import asyncio
import autogen
import pytest
-from conftest import skip_openai
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST
+import sys
+import os
+
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
try:
from openai import OpenAI
diff --git a/test/agentchat/test_function_call.py b/test/agentchat/test_function_call.py
index 54f1f6dff..3f4bdc79a 100644
--- a/test/agentchat/test_function_call.py
+++ b/test/agentchat/test_function_call.py
@@ -2,10 +2,13 @@ import pytest
import asyncio
import json
import autogen
-from conftest import skip_openai
from autogen.math_utils import eval_math_responses
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST
import sys
+import os
+
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
try:
from openai import OpenAI
diff --git a/test/agentchat/test_function_call_groupchat.py b/test/agentchat/test_function_call_groupchat.py
index 7b5266195..cf4b199cd 100644
--- a/test/agentchat/test_function_call_groupchat.py
+++ b/test/agentchat/test_function_call_groupchat.py
@@ -1,9 +1,12 @@
import autogen
import pytest
import sys
-from conftest import skip_openai
+import os
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
+
try:
from openai import OpenAI
except ImportError:
diff --git a/test/agentchat/test_math_user_proxy_agent.py b/test/agentchat/test_math_user_proxy_agent.py
index 787a63f04..c81449cec 100644
--- a/test/agentchat/test_math_user_proxy_agent.py
+++ b/test/agentchat/test_math_user_proxy_agent.py
@@ -1,14 +1,17 @@
import pytest
import sys
+import os
import autogen
from autogen.agentchat.contrib.math_user_proxy_agent import (
MathUserProxyAgent,
_remove_print,
_add_print_to_last_line,
)
-from conftest import skip_openai
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
+
try:
from openai import OpenAI
except ImportError:
diff --git a/test/oai/test_client.py b/test/oai/test_client.py
index 749c272ea..26a053961 100644
--- a/test/oai/test_client.py
+++ b/test/oai/test_client.py
@@ -1,6 +1,10 @@
import pytest
from autogen import OpenAIWrapper, config_list_from_json, config_list_openai_aoai
-from conftest import skip_openai
+import sys
+import os
+
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
TOOL_ENABLED = False
try:
diff --git a/test/oai/test_client_stream.py b/test/oai/test_client_stream.py
index c0ff76071..284df0954 100644
--- a/test/oai/test_client_stream.py
+++ b/test/oai/test_client_stream.py
@@ -1,6 +1,10 @@
import pytest
from autogen import OpenAIWrapper, config_list_from_json, config_list_openai_aoai
-from conftest import skip_openai
+import sys
+import os
+
+sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
+from conftest import skip_openai # noqa: E402
try:
from openai import OpenAI