diff --git a/bot/tests/conftest.py b/bot/tests/conftest.py index 819eb0ac9..2b2ab9951 100644 --- a/bot/tests/conftest.py +++ b/bot/tests/conftest.py @@ -13,6 +13,7 @@ import hglib import pytest import responses +import tenacity FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixtures") @@ -405,3 +406,11 @@ def _sum(name): "linesMissed": _sum("linesMissed"), "linesTotal": _sum("linesTotal"), } + + +@pytest.fixture +def mock_tenacity(monkeypatch): + """ + Mock Tenacity wait function to avoid spening time in unit tests + """ + monkeypatch.setattr(tenacity, "wait_fixed", lambda x: None) diff --git a/bot/tests/test_taskcluster.py b/bot/tests/test_taskcluster.py index 7bcf9d2fa..0b5a88e5f 100644 --- a/bot/tests/test_taskcluster.py +++ b/bot/tests/test_taskcluster.py @@ -2,7 +2,6 @@ import json import os -from unittest import mock from zipfile import BadZipFile import pytest @@ -256,8 +255,7 @@ def test_get_platform(task_name, expected): assert taskcluster.get_platform(task) == expected -@mock.patch("time.sleep") -def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir): +def test_download_artifact_forbidden(mock_taskcluster, tmpdir, mock_tenacity): responses.add( responses.GET, "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", @@ -278,8 +276,7 @@ def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir): assert len(responses.calls) == 5 -@mock.patch("time.sleep") -def test_download_artifact_badzip(mocked_sleep, mock_taskcluster, tmpdir): +def test_download_artifact_badzip(mock_taskcluster, tmpdir, mock_tenacity): responses.add( responses.GET, "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip",