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

Refactor CI hub fixtures to use monkeypatch instead of patch #5208

Merged
merged 2 commits into from
Nov 8, 2022
Merged
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
19 changes: 6 additions & 13 deletions tests/fixtures/hub.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
from contextlib import contextmanager
from pathlib import Path
from unittest.mock import patch

import pytest
import requests
Expand Down Expand Up @@ -97,10 +96,8 @@ def hf_private_dataset_repo_txt_data_(hf_api: HfApi, hf_token, text_file):


@pytest.fixture()
def hf_private_dataset_repo_txt_data(hf_private_dataset_repo_txt_data_):
with patch("datasets.config.HF_ENDPOINT", CI_HUB_ENDPOINT):
with patch("datasets.config.HUB_DATASETS_URL", CI_HUB_DATASETS_URL):
yield hf_private_dataset_repo_txt_data_
def hf_private_dataset_repo_txt_data(hf_private_dataset_repo_txt_data_, ci_hub_config):
return hf_private_dataset_repo_txt_data_


@pytest.fixture(scope="session")
Expand All @@ -123,10 +120,8 @@ def hf_private_dataset_repo_zipped_txt_data_(hf_api: HfApi, hf_token, zip_csv_wi


@pytest.fixture()
def hf_private_dataset_repo_zipped_txt_data(hf_private_dataset_repo_zipped_txt_data_):
with patch("datasets.config.HF_ENDPOINT", CI_HUB_ENDPOINT):
with patch("datasets.config.HUB_DATASETS_URL", CI_HUB_DATASETS_URL):
yield hf_private_dataset_repo_zipped_txt_data_
def hf_private_dataset_repo_zipped_txt_data(hf_private_dataset_repo_zipped_txt_data_, ci_hub_config):
return hf_private_dataset_repo_zipped_txt_data_


@pytest.fixture(scope="session")
Expand All @@ -149,7 +144,5 @@ def hf_private_dataset_repo_zipped_img_data_(hf_api: HfApi, hf_token, zip_image_


@pytest.fixture()
def hf_private_dataset_repo_zipped_img_data(hf_private_dataset_repo_zipped_img_data_):
with patch("datasets.config.HF_ENDPOINT", CI_HUB_ENDPOINT):
with patch("datasets.config.HUB_DATASETS_URL", CI_HUB_DATASETS_URL):
yield hf_private_dataset_repo_zipped_img_data_
def hf_private_dataset_repo_zipped_img_data(hf_private_dataset_repo_zipped_img_data_, ci_hub_config):
return hf_private_dataset_repo_zipped_img_data_