|
11 | 11 | import fsspec
|
12 | 12 | import pytest
|
13 | 13 |
|
14 |
| -from huggingface_hub import hf_file_system |
| 14 | +from huggingface_hub import constants, hf_file_system |
15 | 15 | from huggingface_hub.errors import RepositoryNotFoundError, RevisionNotFoundError
|
16 |
| -from huggingface_hub.hf_file_system import HfFileSystem, HfFileSystemFile, HfFileSystemStreamFile |
| 16 | +from huggingface_hub.hf_file_system import ( |
| 17 | + HfFileSystem, |
| 18 | + HfFileSystemFile, |
| 19 | + HfFileSystemStreamFile, |
| 20 | +) |
17 | 21 |
|
18 | 22 | from .testing_constants import ENDPOINT_STAGING, TOKEN
|
19 |
| -from .testing_utils import repo_name |
| 23 | +from .testing_utils import repo_name, with_production_testing |
20 | 24 |
|
21 | 25 |
|
22 | 26 | class HfFileSystemTests(unittest.TestCase):
|
@@ -612,3 +616,13 @@ def test_exists_after_repo_deletion():
|
612 | 616 | api.delete_repo(repo_id=repo_id, repo_type="model")
|
613 | 617 | # Verify that the repo no longer exists.
|
614 | 618 | assert not hffs.exists(repo_id, refresh=True)
|
| 619 | + |
| 620 | + |
| 621 | +@with_production_testing |
| 622 | +def test_hf_file_system_file_can_handle_gzipped_file(): |
| 623 | + """Test that HfFileSystemStreamFile.read() can handle gzipped files.""" |
| 624 | + fs = HfFileSystem(endpoint=constants.ENDPOINT) |
| 625 | + # As of July 2025, the math_qa.py file is gzipped when queried from production: |
| 626 | + with fs.open("datasets/allenai/math_qa/math_qa.py", "r", encoding="utf-8") as f: |
| 627 | + out = f.read() |
| 628 | + assert "class MathQa" in out |
0 commit comments