From 363dcf6ff09781ad3c862d549dabac6dc5209b8b Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 16 Feb 2026 17:21:52 +0100 Subject: [PATCH] Remove static sleeps --- changedetectionio/tests/test_backend.py | 2 -- changedetectionio/tests/test_extract_csv.py | 4 ---- .../tests/test_ignorehyperlinks.py | 1 - .../tests/test_ignorestatuscode.py | 4 +--- .../tests/test_ignorewhitespace.py | 12 ++++------- changedetectionio/tests/test_share_watch.py | 3 --- changedetectionio/tests/test_source.py | 6 ++++-- .../tests/test_trigger_regex_with_filter.py | 20 +++++++++---------- 8 files changed, 19 insertions(+), 33 deletions(-) diff --git a/changedetectionio/tests/test_backend.py b/changedetectionio/tests/test_backend.py index dcebf2df..6a04ee67 100644 --- a/changedetectionio/tests/test_backend.py +++ b/changedetectionio/tests/test_backend.py @@ -6,8 +6,6 @@ from flask import url_for from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks, extract_rss_token_from_UI, \ extract_UUID_from_client, delete_all_watches -sleep_time_for_fetch_thread = 3 - # Basic test to check inscriptus is not adding return line chars, basically works etc def test_inscriptus(): diff --git a/changedetectionio/tests/test_extract_csv.py b/changedetectionio/tests/test_extract_csv.py index 69466e43..6b0ade79 100644 --- a/changedetectionio/tests/test_extract_csv.py +++ b/changedetectionio/tests/test_extract_csv.py @@ -6,10 +6,6 @@ from urllib.request import urlopen from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks import os -sleep_time_for_fetch_thread = 3 - - - def test_check_extract_text_from_diff(client, live_server, measure_memory_usage, datastore_path): import time with open(os.path.join(datastore_path, "endpoint-content.txt"), "w") as f: diff --git a/changedetectionio/tests/test_ignorehyperlinks.py b/changedetectionio/tests/test_ignorehyperlinks.py index 2e870d5f..b1a3477c 100644 --- a/changedetectionio/tests/test_ignorehyperlinks.py +++ b/changedetectionio/tests/test_ignorehyperlinks.py @@ -41,7 +41,6 @@ def set_modified_ignore_response(datastore_path): def test_render_anchor_tag_content_true(client, live_server, measure_memory_usage, datastore_path): """Testing that the link changes are detected when render_anchor_tag_content setting is set to true""" - sleep_time_for_fetch_thread = 3 # Give the endpoint time to spin up time.sleep(1) diff --git a/changedetectionio/tests/test_ignorestatuscode.py b/changedetectionio/tests/test_ignorestatuscode.py index 4a062b13..f3b9fe47 100644 --- a/changedetectionio/tests/test_ignorestatuscode.py +++ b/changedetectionio/tests/test_ignorestatuscode.py @@ -100,7 +100,6 @@ def test_normal_page_check_works_with_ignore_status_code(client, live_server, me # Tests the whole stack works with staus codes ignored def test_403_page_check_works_with_ignore_status_code(client, live_server, measure_memory_usage, datastore_path): - sleep_time_for_fetch_thread = 3 set_original_response(datastore_path=datastore_path) @@ -112,8 +111,7 @@ def test_403_page_check_works_with_ignore_status_code(client, live_server, measu uuid = client.application.config.get('DATASTORE').add_watch(url=test_url) client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) - # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # Goto the edit page, check our ignore option # Add our URL to the import page diff --git a/changedetectionio/tests/test_ignorewhitespace.py b/changedetectionio/tests/test_ignorewhitespace.py index ed0a53b6..cf158da4 100644 --- a/changedetectionio/tests/test_ignorewhitespace.py +++ b/changedetectionio/tests/test_ignorewhitespace.py @@ -2,10 +2,9 @@ import time from flask import url_for -from . util import live_server_setup import os - +from .util import live_server_setup, delete_all_watches, wait_for_all_checks # Should be the same as set_original_ignore_response(datastore_path=datastore_path) but with a little more whitespacing @@ -50,10 +49,7 @@ def set_original_ignore_response(datastore_path): # If there was only a change in the whitespacing, then we shouldnt have a change detected def test_check_ignore_whitespace(client, live_server, measure_memory_usage, datastore_path): - sleep_time_for_fetch_thread = 3 - # Give the endpoint time to spin up - time.sleep(1) set_original_ignore_response(datastore_path=datastore_path) @@ -74,17 +70,17 @@ def test_check_ignore_whitespace(client, live_server, measure_memory_usage, data uuid = client.application.config.get('DATASTORE').add_watch(url=test_url) client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # Trigger a check client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) set_original_ignore_response_but_with_whitespace(datastore_path) - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # Trigger a check client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # It should report nothing found (no new 'has-unread-changes' class) res = client.get(url_for("watchlist.index")) diff --git a/changedetectionio/tests/test_share_watch.py b/changedetectionio/tests/test_share_watch.py index 5c2707e2..025b2f2c 100644 --- a/changedetectionio/tests/test_share_watch.py +++ b/changedetectionio/tests/test_share_watch.py @@ -6,9 +6,6 @@ from urllib.request import urlopen from .util import set_original_response, set_modified_response, live_server_setup, delete_all_watches import re -sleep_time_for_fetch_thread = 3 - - def test_share_watch(client, live_server, measure_memory_usage, datastore_path): set_original_response(datastore_path=datastore_path) diff --git a/changedetectionio/tests/test_source.py b/changedetectionio/tests/test_source.py index 14975c51..e0bbf649 100644 --- a/changedetectionio/tests/test_source.py +++ b/changedetectionio/tests/test_source.py @@ -6,7 +6,6 @@ from urllib.request import urlopen from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks from ..diff import ADDED_STYLE -sleep_time_for_fetch_thread = 3 def test_check_basic_change_detection_functionality_source(client, live_server, measure_memory_usage, datastore_path): set_original_response(datastore_path=datastore_path) @@ -72,7 +71,10 @@ def test_check_ignore_elements(client, live_server, measure_memory_usage, datast follow_redirects=True ) - time.sleep(sleep_time_for_fetch_thread) + client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) + + wait_for_all_checks(client) + res = client.get( url_for("ui.ui_preview.preview_page", uuid="first"), diff --git a/changedetectionio/tests/test_trigger_regex_with_filter.py b/changedetectionio/tests/test_trigger_regex_with_filter.py index e3b85aa5..28db3a5c 100644 --- a/changedetectionio/tests/test_trigger_regex_with_filter.py +++ b/changedetectionio/tests/test_trigger_regex_with_filter.py @@ -2,7 +2,8 @@ import time from flask import url_for -from . util import live_server_setup, delete_all_watches + +from .util import live_server_setup, delete_all_watches, wait_for_all_checks import os @@ -25,9 +26,6 @@ def set_original_ignore_response(datastore_path): def test_trigger_regex_functionality_with_filter(client, live_server, measure_memory_usage, datastore_path): - # live_server_setup(live_server) # Setup on conftest per function - sleep_time_for_fetch_thread = 3 - set_original_ignore_response(datastore_path=datastore_path) # Give the endpoint time to spin up @@ -38,8 +36,7 @@ def test_trigger_regex_functionality_with_filter(client, live_server, measure_me uuid = client.application.config.get('DATASTORE').add_watch(url=test_url) client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) - # it needs time to save the original version - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) ### test regex with filter res = client.post( @@ -52,8 +49,9 @@ def test_trigger_regex_functionality_with_filter(client, live_server, measure_me follow_redirects=True ) - # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) + client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) + + wait_for_all_checks(client) client.get(url_for("ui.ui_diff.diff_history_page", uuid="first")) @@ -62,7 +60,8 @@ def test_trigger_regex_functionality_with_filter(client, live_server, measure_me f.write("some new noise with cool stuff2 ok") client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) - time.sleep(sleep_time_for_fetch_thread) + + wait_for_all_checks(client) # It should report nothing found (nothing should match the regex and filter) res = client.get(url_for("watchlist.index")) @@ -73,7 +72,8 @@ def test_trigger_regex_functionality_with_filter(client, live_server, measure_me f.write("some new noise with cool stuff6 ok") client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) - time.sleep(sleep_time_for_fetch_thread) + + wait_for_all_checks(client) res = client.get(url_for("watchlist.index")) assert b'has-unread-changes' in res.data