From 83357adccb0db9d2dc53940ac61d5d6be13f6070 Mon Sep 17 00:00:00 2001 From: "Loic A. Royer" Date: Fri, 30 Aug 2024 20:46:13 -0400 Subject: [PATCH] fixing tests on CI --- src/napari_chatgpt/utils/web/test/wikipedia_test.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/napari_chatgpt/utils/web/test/wikipedia_test.py b/src/napari_chatgpt/utils/web/test/wikipedia_test.py index 9c9fcac..b1d849e 100644 --- a/src/napari_chatgpt/utils/web/test/wikipedia_test.py +++ b/src/napari_chatgpt/utils/web/test/wikipedia_test.py @@ -5,7 +5,12 @@ from napari_chatgpt.utils.api_keys.api_key import is_api_key_available from napari_chatgpt.utils.web.wikipedia import search_wikipedia +import os +# Skip tests that require API keys in Github Actions +IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" + +@pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test doesn't work in Github Actions.") def test_wikipedia_search_MM(): try: @@ -24,11 +29,8 @@ def test_wikipedia_search_MM(): import traceback traceback.print_exc() - - - -@pytest.mark.skipif(not is_api_key_available('OpenAI'), - reason="requires OpenAI key to run") +@pytest.mark.skipif(IN_GITHUB_ACTIONS or not is_api_key_available('OpenAI'), + reason="requires OpenAI key to run and doesn't work in Github Actions.") def test_wikipedia_search_AE(): try: