This commit is contained in:
yzlin 2024-01-03 12:51:25 +08:00
commit 41cc9ceab6
5 changed files with 9 additions and 6 deletions

View file

@ -23,7 +23,7 @@ jobs:
- name: Test with pytest
run: |
echo "${{ secrets.METAGPT_KEY_YAML }}" | base64 -d > config/key.yaml
pytest tests/ --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20
pytest tests/ --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 | tee unittest.txt
- name: Show coverage report
run: |
coverage report -m
@ -32,7 +32,7 @@ jobs:
with:
name: pytest-results-${{ matrix.python-version }}
path: |
./junit/test-results-${{ matrix.python-version }}.xml
./unittest.txt
./htmlcov/
./tests/data/rsp_cache_new.json
retention-days: 3

1
.gitignore vendored
View file

@ -52,6 +52,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
unittest.txt
# Translations
*.mo

View file

@ -18,7 +18,7 @@ class SerpAPIWrapper(BaseModel):
search_engine: Any = None #: :meta private:
params: dict = Field(
default={
default_factory=lambda: {
"engine": "google",
"google_domain": "google.com",
"gl": "us",

View file

@ -9,14 +9,16 @@ import json
from typing import Any, Dict, Optional, Tuple
import aiohttp
from pydantic import BaseModel, Field, field_validator
from pydantic import BaseModel, ConfigDict, Field, field_validator
from metagpt.config import CONFIG
class SerperWrapper(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
search_engine: Any = None #: :meta private:
payload: dict = Field(default={"page": 1, "num": 10})
payload: dict = Field(default_factory=lambda: {"page": 1, "num": 10})
serper_api_key: Optional[str] = Field(default=None, validate_default=True)
aiosession: Optional[aiohttp.ClientSession] = None

View file

@ -58,7 +58,7 @@ async def test_search_engine(search_engine_type, run_func: Callable, max_results
assert isinstance(rsp, str)
else:
assert isinstance(rsp, list)
assert len(rsp) == max_results
assert len(rsp) <= max_results
if __name__ == "__main__":