File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change 22license_file = LICENSE
33
44[tool:pytest]
5+ # Test fails if a FutureWarning is thrown by `huggingface_hub`
6+ filterwarnings =
7+ error::FutureWarning:huggingface_hub*
58markers =
69 unit: unit test
710 integration: integration test
Original file line number Diff line number Diff line change @@ -39,12 +39,9 @@ def ci_hub_token_path(monkeypatch):
3939
4040@pytest .fixture
4141def set_ci_hub_access_token (ci_hub_config , ci_hub_token_path ):
42- _api = HfApi (endpoint = CI_HUB_ENDPOINT )
43- _api .set_access_token (CI_HUB_USER_TOKEN )
4442 HfFolder .save_token (CI_HUB_USER_TOKEN )
4543 yield
4644 HfFolder .delete_token ()
47- _api .unset_access_token ()
4845
4946
5047@pytest .fixture (scope = "session" )
@@ -54,14 +51,11 @@ def hf_api():
5451
5552@pytest .fixture (scope = "session" )
5653def hf_token (hf_api : HfApi ):
57- hf_api . set_access_token ( CI_HUB_USER_TOKEN )
54+ previous_token = HfFolder . get_token ( )
5855 HfFolder .save_token (CI_HUB_USER_TOKEN )
59-
6056 yield CI_HUB_USER_TOKEN
61- try :
62- hf_api .unset_access_token ()
63- except requests .exceptions .HTTPError :
64- pass
57+ if previous_token is not None :
58+ HfFolder .save_token (previous_token )
6559
6660
6761@pytest .fixture
You can’t perform that action at this time.
0 commit comments