From efa5131648264c9e670bc95ddac64e8fd87683a1 Mon Sep 17 00:00:00 2001 From: Hynek Kydlicek Date: Fri, 13 Sep 2024 12:16:36 +0200 Subject: [PATCH] skip tests if secrets not provided --- tests/fixtures.py | 2 +- tests/logging/test_evaluation_tracker.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index ac1b97fb3..d14e542fb 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -34,7 +34,7 @@ @pytest.fixture def testing_empty_hf_org_id(org_id: str = TESTING_EMPTY_HF_ORG_ID): old_token = os.getenv("HF_TOKEN") - os.environ["HF_TOKEN"] = os.getenv("HF_TEST_TOKEN") + os.environ["HF_TOKEN"] = os.getenv("HF_TEST_TOKEN") or "" def list_repos(org_id: str): return list(hf_api.list_models(author=org_id)) + list(hf_api.list_datasets(author=org_id)) diff --git a/tests/logging/test_evaluation_tracker.py b/tests/logging/test_evaluation_tracker.py index 1712616b9..a3df1e375 100644 --- a/tests/logging/test_evaluation_tracker.py +++ b/tests/logging/test_evaluation_tracker.py @@ -126,6 +126,10 @@ def test_no_details_output(mock_evaluation_tracker: EvaluationTracker): assert not details_dir.exists() +@pytest.mark.skipif( + reason="Secrets are not available in this environment", + condition=os.getenv("HF_TEST_TOKEN") is None, +) @pytest.mark.evaluation_tracker(push_to_hub=True, hub_results_org=TESTING_EMPTY_HF_ORG_ID) def test_push_to_hub_works(testing_empty_hf_org_id, mock_evaluation_tracker: EvaluationTracker, mock_datetime): # Prepare the dummy data