add agent subscription

This commit is contained in:
shenchucheng 2023-12-01 16:10:38 +08:00
parent 6f345002c4
commit dfc6e13ac3
3 changed files with 217 additions and 2 deletions

View file

@ -6,14 +6,15 @@
@File : conftest.py
"""
import asyncio
import logging
import re
from unittest.mock import Mock
import pytest
from metagpt.logs import logger
from metagpt.provider.openai_api import OpenAIGPTAPI as GPTAPI
import asyncio
import re
class Context:
@ -68,3 +69,14 @@ def proxy():
server = asyncio.get_event_loop().run_until_complete(asyncio.start_server(handle_client, "127.0.0.1", 0))
return "http://{}:{}".format(*server.sockets[0].getsockname())
# see https://github.com/Delgan/loguru/issues/59#issuecomment-466591978
@pytest.fixture
def loguru_caplog(caplog):
class PropogateHandler(logging.Handler):
def emit(self, record):
logging.getLogger(record.name).handle(record)
logger.add(PropogateHandler(), format="{message}")
yield caplog