Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Benchmarks write cassettes without using them #4664

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Run pytest with coverage
run: |
rm -rf tests/Auto-GPT-test-cassettes
pytest -n auto ${{ matrix.config.task }}
pytest -n auto --record-mode=all ${{ matrix.config.task }}
env:
CI: true
PROXY: ${{ secrets.PROXY }}
Expand Down
6 changes: 3 additions & 3 deletions tests/challenges/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from _pytest.fixtures import FixtureRequest

from tests.challenges.challenge_decorator.challenge import Challenge
from tests.vcr import BASE_VCR_CONFIG, before_record_response
from tests.vcr import before_record_response


def before_record_response_filter_errors(
Expand All @@ -20,9 +20,9 @@ def before_record_response_filter_errors(


@pytest.fixture(scope="module")
def vcr_config() -> Dict[str, Any]:
def vcr_config(get_base_vcr_config: Dict[str, Any]) -> Dict[str, Any]:
# this fixture is called by the pytest-recording vcr decorator.
return BASE_VCR_CONFIG | {
return get_base_vcr_config | {
"before_record_response": before_record_response_filter_errors,
}

Expand Down
18 changes: 14 additions & 4 deletions tests/vcr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from .vcr_filter import PROXY, before_record_request, before_record_response

DEFAULT_RECORD_MODE = "new_episodes"
BASE_VCR_CONFIG = {
"record_mode": "new_episodes",
"before_record_request": before_record_request,
"before_record_response": before_record_response,
"filter_headers": [
Expand All @@ -20,9 +20,19 @@


@pytest.fixture(scope="session")
def vcr_config():
# this fixture is called by the pytest-recording vcr decorator.
return BASE_VCR_CONFIG
def vcr_config(get_base_vcr_config):
return get_base_vcr_config


@pytest.fixture(scope="session")
def get_base_vcr_config(request):
record_mode = request.config.getoption("--record-mode", default="new_episodes")
config = BASE_VCR_CONFIG

if record_mode is None:
config["record_mode"] = DEFAULT_RECORD_MODE

return config


@pytest.fixture()
Expand Down