Compare commits

...
Author SHA1 Message Date
praisonai-triage-agent[bot]andMervin Praison 6c41174888 fix: restore test safety plugins and correct core SDK path in conftest
Register the test_gating and network_guard plugins via
config.pluginmanager.import_plugin() in pytest_configure, which is the
supported mechanism for non-top-level conftest files under pytest 9.1.1+.
This restores test gating and network-guard enforcement that was dropped
when pytest_plugins was removed.

Also fix the core SDK sys.path insertion: praisonaiagents lives at
src/praisonai-agents, so traverse two parents ('..','..') to reach
<root>/src, not three.

Co-authored-by: Mervin Praison <[email protected]>
2026-07-27 13:43:05 +00:00
Hore01 02c1c87d58 fix: Remove pytest_plugins from conftest to resolve pytest error 2026-07-27 14:30:07 +01:00
+25 -11
View File
@@ -6,12 +6,24 @@ import warnings
import gc
from unittest.mock import Mock, patch
# Register pytest plugins
pytest_plugins = (
'pytest_asyncio',
'tests._pytest_plugins.test_gating',
'tests._pytest_plugins.network_guard',
)
# NOTE: pytest 9.1.1+ forbids declaring `pytest_plugins` in a non-top-level
# conftest.py. We register the local safety plugins here instead, which is the
# supported mechanism for nested conftest files. This preserves the test gating
# and network guard behaviour without triggering the collection error.
def pytest_configure(config):
"""Register local safety plugins for the PraisonAI test suite.
pytest-asyncio is loaded automatically via its entry point. The gating and
network-guard plugins are registered explicitly (they previously lived in a
module-level `pytest_plugins` tuple which is no longer allowed here).
"""
for plugin_name in (
"tests._pytest_plugins.test_gating",
"tests._pytest_plugins.network_guard",
):
if not config.pluginmanager.has_plugin(plugin_name):
config.pluginmanager.import_plugin(plugin_name)
# Suppress aiohttp unclosed session warnings during tests
warnings.filterwarnings("ignore", message="Unclosed client session")
@@ -44,14 +56,16 @@ def cleanup_async_resources():
# Force garbage collection to clean up any lingering async resources
gc.collect()
# Add the source paths to sys.path for imports
# praisonai-agents package (core SDK)
# Add the source paths to sys.path for imports.
# Layout: <root>/src/praisonai/tests/conftest.py, with the core SDK living at
# <root>/src/praisonai-agents. From this file, '..', '..' reaches <root>/src.
_agents_path = os.path.join(os.path.dirname(__file__), '..', '..', 'praisonai-agents')
if _agents_path not in sys.path:
if os.path.isdir(_agents_path) and _agents_path not in sys.path:
sys.path.insert(0, _agents_path)
# praisonai wrapper package
# praisonai wrapper package: '..' reaches <root>/src/praisonai.
_wrapper_path = os.path.join(os.path.dirname(__file__), '..')
if _wrapper_path not in sys.path:
if os.path.isdir(_wrapper_path) and _wrapper_path not in sys.path:
sys.path.insert(0, _wrapper_path)
@pytest.fixture