ee3943b5b1
CI / test (deps-minimum, windows-latest, unit) (push) Blocked by required conditions
CI / test_py314 (deps-latest, ubuntu-latest, unit) (push) Blocked by required conditions
CI / test_py314 (deps-latest, windows-latest, unit) (push) Blocked by required conditions
CI / test_py314_future (deps-latest, ubuntu-latest, unit) (push) Blocked by required conditions
CI / test_py314_future (deps-latest, windows-latest, unit) (push) Blocked by required conditions
Secret Leaks / trufflehog (push) Waiting to run
CI / check_code_quality (push) Waiting to run
CI / test (deps-latest, ubuntu-latest, integration) (push) Blocked by required conditions
CI / test (deps-latest, ubuntu-latest, unit) (push) Blocked by required conditions
CI / test (deps-latest, windows-latest, integration) (push) Blocked by required conditions
CI / test (deps-latest, windows-latest, unit) (push) Blocked by required conditions
CI / test (deps-minimum, ubuntu-latest, integration) (push) Blocked by required conditions
CI / test (deps-minimum, ubuntu-latest, unit) (push) Blocked by required conditions
CI / test (deps-minimum, windows-latest, integration) (push) Blocked by required conditions
Build documentation / build (push) Failing after 0s
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
import pytest
|
|
|
|
import datasets
|
|
import datasets.config
|
|
|
|
|
|
# Import fixture modules as plugins
|
|
pytest_plugins = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]
|
|
|
|
|
|
def pytest_collection_modifyitems(config, items):
|
|
# Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit")
|
|
for item in items:
|
|
if any(marker in item.keywords for marker in ["integration", "unit"]):
|
|
continue
|
|
item.add_marker(pytest.mark.unit)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def set_test_cache_config(tmp_path_factory, monkeypatch):
|
|
# test_hf_cache_home = tmp_path_factory.mktemp("cache") # TODO: why a cache dir per test function does not work?
|
|
test_hf_cache_home = tmp_path_factory.getbasetemp() / "cache"
|
|
test_hf_datasets_cache = test_hf_cache_home / "datasets"
|
|
monkeypatch.setattr("datasets.config.HF_DATASETS_CACHE", str(test_hf_datasets_cache))
|
|
test_downloaded_datasets_path = test_hf_datasets_cache / "downloads"
|
|
monkeypatch.setattr("datasets.config.DOWNLOADED_DATASETS_PATH", str(test_downloaded_datasets_path))
|
|
test_extracted_datasets_path = test_hf_datasets_cache / "downloads" / "extracted"
|
|
monkeypatch.setattr("datasets.config.EXTRACTED_DATASETS_PATH", str(test_extracted_datasets_path))
|
|
|
|
# used in dataset viewer, we may set it to true by default in the future
|
|
monkeypatch.setattr("datasets.config.SAVE_ORIGINAL_SHARD_LENGTHS", True)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def disable_implicit_token(monkeypatch):
|
|
monkeypatch.setattr("huggingface_hub.constants.HF_HUB_DISABLE_IMPLICIT_TOKEN", True)
|
|
|
|
|
|
@pytest.fixture(autouse=True, scope="session")
|
|
def disable_tqdm_output():
|
|
datasets.disable_progress_bar()
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def set_update_download_counts_to_false(monkeypatch):
|
|
# don't take tests into account when counting downloads
|
|
monkeypatch.setattr("datasets.config.HF_UPDATE_DOWNLOAD_COUNTS", False)
|
|
|
|
|
|
@pytest.fixture
|
|
def set_sqlalchemy_silence_uber_warning(monkeypatch):
|
|
# Required to suppress RemovedIn20Warning when feature(s) are not compatible with SQLAlchemy 2.0
|
|
# To be removed once SQLAlchemy 2.0 supported
|
|
try:
|
|
monkeypatch.setattr("sqlalchemy.util.deprecations.SILENCE_UBER_WARNING", True)
|
|
except (ModuleNotFoundError, AttributeError):
|
|
pass
|
|
|
|
|
|
@pytest.fixture(autouse=True, scope="session")
|
|
def zero_time_out_for_remote_code():
|
|
datasets.config.TIME_OUT_REMOTE_CODE = 0
|