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

* Runnig tests directly

* All tests with contrib add sys.path
This commit is contained in:
Maxim Saplin 2024-01-05 17:24:49 +03:00 committed by GitHub
parent 55b03bfac6
commit 3f343654bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 48 additions and 14 deletions

View File

@ -300,7 +300,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.11.6"
}
},
"nbformat": 4,

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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