Skip to content

Commit d4d4a16

Browse files
authored
Merge pull request #694 from garylin2099/llm_mock
enforce mock on online test
2 parents aacb55c + 8fb5919 commit d4d4a16

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

.github/workflows/unittest.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ jobs:
2929
sh tests/scripts/run_install_deps.sh
3030
- name: Test with pytest
3131
run: |
32+
export ALLOW_OPENAI_API_CALL=0
3233
echo "${{ secrets.METAGPT_KEY_YAML }}" | base64 -d > config/key.yaml
3334
pytest tests/ --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 | tee unittest.txt
3435
- name: Show coverage report
3536
run: |
3637
coverage report -m
3738
- name: Show failed tests and overall summary
3839
run: |
39-
grep -E "FAILED tests|[0-9]+ passed," unittest.txt
40-
failed_count=$(grep "FAILED" unittest.txt | wc -l)
40+
grep -E "FAILED tests|ERROR tests|[0-9]+ passed," unittest.txt
41+
failed_count=$(grep "FAILED|ERROR" unittest.txt | wc -l)
4142
if [[ "$failed_count" -gt 0 ]]; then
4243
echo "$failed_count failed lines found! Task failed."
4344
exit 1

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
from tests.mock.mock_llm import MockLLM
2424

2525
RSP_CACHE_NEW = {} # used globally for producing new and useful only response cache
26-
ALLOW_OPENAI_API_CALL = os.environ.get(
27-
"ALLOW_OPENAI_API_CALL", True
28-
) # NOTE: should change to default False once mock is complete
26+
ALLOW_OPENAI_API_CALL = int(
27+
os.environ.get("ALLOW_OPENAI_API_CALL", 1)
28+
) # NOTE: should change to default 0 (False) once mock is complete
2929

3030

3131
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)