Skip to content

[Bug]: [Medium Priority] Scripts under the test dir can no longer be run manually #1137

@rickyloynd-microsoft

Description

@rickyloynd-microsoft

Describe the bug

A change made by #1097 interferes with manual testing (not using pytest) of many scripts under the test dir because they now contain the following import:

from conftest import skip_openai

#1097 added test/conftest.py, but the test dir is not normally in sys.path, so manually running a script fails with this error:

ModuleNotFoundError: No module named 'conftest'

Maybe pytest avoids this error by appending the test dir to sys.path.

One solution is to add a line like the following right before the import of skip_openai:

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))

Similarly, 7 of our test scripts (like test_gpt_assistant.py) already append to sys.path in order to import from test_assistant_agent:

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

I can make a PR modifying sys.path so that scripts under test can find conftest when run manually. Or is there a simpler solution?

Steps to reproduce

python test/agentchat/contrib/test_teachable_agent.py

Expected Behavior

The test should run to completion.

Screenshots and logs

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.2Issues which are related to the pre 0.4 codebase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions