From 41e19d3053a6f4c99c0a8ad970b6d2510a656875 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Mon, 8 Sep 2025 16:30:24 +0000 Subject: [PATCH] Bug 1987457 - freeze date in unit test to avoid spurious failures when test variants expire r=jmaher a=test-only DONTBUILD --- tools/tryselect/test/test_fuzzy.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/tryselect/test/test_fuzzy.py b/tools/tryselect/test/test_fuzzy.py index a4bda4b7eae2..64239e6a0e35 100644 --- a/tools/tryselect/test/test_fuzzy.py +++ b/tools/tryselect/test/test_fuzzy.py @@ -2,8 +2,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import datetime import json import os +from unittest.mock import MagicMock import mozunit import pytest @@ -70,7 +72,14 @@ def test_query_paths_no_chunks(run_mach, capfd, show_chunk_numbers): @pytest.mark.skipif(os.name == "nt", reason="fzf not installed on host") @pytest.mark.parametrize("variant", ["", "spi-nw"]) -def test_query_paths_variants(run_mach, capfd, variant): +def test_query_paths_variants(monkeypatch, run_mach, capfd, variant): + # Freeze time to avoid test failures due to an expired variant + datetime_mock = MagicMock(wraps=datetime.datetime) + datetime_mock.today.return_value = datetime.datetime.strptime( + "2025-08-01", "%Y-%m-%d" + ) + monkeypatch.setattr(datetime, "datetime", datetime_mock) + if variant: variant = "-%s" % variant