Skip to content

Unskip and fix test_offline_mode by using HF_HUB_OFFLINE and hermetic cache warmup #41311

@arvinder004

Description

@arvinder004

tests/utils/test_offline.py::OfflineTests::test_offline_mode was skipped and relied on TRANSFORMERS_OFFLINE. Update to use HF_HUB_OFFLINE=1 and make the test hermetic by warming the cache in a first subprocess run, then running offline with socket mocking to forbid network access.

Affected area:

File: tests/utils/test_offline.py
Test: OfflineTests::test_offline_mode

Problem:

Test was @unittest.skip with a TODO.
Behavior depended on environment set after import and on external cache state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions