From 8f3a6a42bcd4b25239ce29a769d3ff2f72f38e1a Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 11 Jul 2024 15:03:42 +0200 Subject: [PATCH] Testing - Adding simple memory usage test (#2483) --- changedetectionio/tests/conftest.py | 33 +++++++++++++++++++ .../test_custom_browser_url.py | 4 +-- .../tests/fetchers/test_content.py | 2 +- .../fetchers/test_custom_js_before_content.py | 2 +- .../tests/proxy_list/test_multiple_proxy.py | 2 +- .../tests/proxy_list/test_noproxy.py | 2 +- .../tests/proxy_list/test_proxy.py | 2 +- .../proxy_list/test_select_custom_proxy.py | 2 +- .../tests/proxy_socks5/test_socks5_proxy.py | 2 +- .../proxy_socks5/test_socks5_proxy_sources.py | 2 +- .../tests/restock/test_restock.py | 2 +- .../tests/smtp/test_notification_smtp.py | 4 +-- .../tests/test_add_replace_remove_filter.py | 6 ++-- changedetectionio/tests/test_api.py | 10 +++--- changedetectionio/tests/test_auth.py | 2 +- .../test_automatic_follow_ldjson_price.py | 6 ++-- changedetectionio/tests/test_backend.py | 2 +- changedetectionio/tests/test_backup.py | 2 +- .../tests/test_block_while_text_present.py | 2 +- changedetectionio/tests/test_clone.py | 2 +- changedetectionio/tests/test_css_selector.py | 6 ++-- .../tests/test_element_removal.py | 2 +- changedetectionio/tests/test_encoding.py | 4 +-- changedetectionio/tests/test_errorhandling.py | 6 ++-- changedetectionio/tests/test_extract_csv.py | 2 +- changedetectionio/tests/test_extract_regex.py | 8 ++--- .../tests/test_filter_exist_changes.py | 2 +- .../tests/test_filter_failure_notification.py | 4 +-- changedetectionio/tests/test_group.py | 18 +++++----- .../tests/test_history_consistency.py | 2 +- changedetectionio/tests/test_ignore_text.py | 4 +-- .../tests/test_ignorehighlighter.py | 2 +- .../tests/test_ignorehyperlinks.py | 2 +- .../tests/test_ignorestatuscode.py | 4 +-- .../tests/test_ignorewhitespace.py | 2 +- changedetectionio/tests/test_import.py | 12 +++---- changedetectionio/tests/test_jinja2.py | 6 ++-- .../tests/test_jsonpath_jq_selector.py | 24 +++++++------- .../tests/test_nonrenderable_pages.py | 2 +- changedetectionio/tests/test_notification.py | 6 ++-- .../tests/test_notification_errors.py | 2 +- changedetectionio/tests/test_obfuscations.py | 2 +- changedetectionio/tests/test_pdf.py | 2 +- changedetectionio/tests/test_request.py | 10 +++--- changedetectionio/tests/test_rss.py | 8 ++--- changedetectionio/tests/test_search.py | 4 +-- changedetectionio/tests/test_security.py | 6 ++-- changedetectionio/tests/test_share_watch.py | 2 +- changedetectionio/tests/test_source.py | 4 +-- changedetectionio/tests/test_trigger.py | 2 +- changedetectionio/tests/test_trigger_regex.py | 2 +- .../tests/test_trigger_regex_with_filter.py | 2 +- changedetectionio/tests/test_unique_lines.py | 6 ++-- .../tests/test_watch_fields_storage.py | 2 +- .../tests/test_xpath_selector.py | 26 +++++++-------- .../tests/visualselector/test_fetch_data.py | 6 ++-- 56 files changed, 164 insertions(+), 131 deletions(-) diff --git a/changedetectionio/tests/conftest.py b/changedetectionio/tests/conftest.py index 7a328823..853d79bd 100644 --- a/changedetectionio/tests/conftest.py +++ b/changedetectionio/tests/conftest.py @@ -1,4 +1,7 @@ #!/usr/bin/python3 +import resource +import time +from threading import Thread import pytest from changedetectionio import changedetection_app @@ -23,6 +26,36 @@ def reportlog(pytestconfig): yield logger.remove(handler_id) + +def track_memory(memory_usage, ): + while not memory_usage["stop"]: + max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + memory_usage["peak"] = max(memory_usage["peak"], max_rss) + time.sleep(0.01) # Adjust the sleep time as needed + +@pytest.fixture(scope='function') +def measure_memory_usage(request): + memory_usage = {"peak": 0, "stop": False} + tracker_thread = Thread(target=track_memory, args=(memory_usage,)) + tracker_thread.start() + + yield + + memory_usage["stop"] = True + tracker_thread.join() + + # Note: ru_maxrss is in kilobytes on Unix-based systems + max_memory_used = memory_usage["peak"] / 1024 # Convert to MB + s = f"Peak memory used by the test {request.node.fspath} - '{request.node.name}': {max_memory_used:.2f} MB" + logger.debug(s) + + with open("test-memory.log", 'a') as f: + f.write(f"{s}\n") + + # Assert that the memory usage is less than 200MB + assert max_memory_used < 150, f"Memory usage exceeded 200MB: {max_memory_used:.2f} MB" + + def cleanup(datastore_path): import glob # Unlink test output files diff --git a/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py b/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py index 212d2e27..dcb93d15 100644 --- a/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py +++ b/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py @@ -77,13 +77,13 @@ def do_test(client, live_server, make_test_use_extra_browser=False): # Requires playwright to be installed -def test_request_via_custom_browser_url(client, live_server): +def test_request_via_custom_browser_url(client, live_server, measure_memory_usage): live_server_setup(live_server) # We do this so we can grep the logs of the custom container and see if the request actually went through that container do_test(client, live_server, make_test_use_extra_browser=True) -def test_request_not_via_custom_browser_url(client, live_server): +def test_request_not_via_custom_browser_url(client, live_server, measure_memory_usage): live_server_setup(live_server) # We do this so we can grep the logs of the custom container and see if the request actually went through that container do_test(client, live_server, make_test_use_extra_browser=False) diff --git a/changedetectionio/tests/fetchers/test_content.py b/changedetectionio/tests/fetchers/test_content.py index bbabe5f1..7ee43c65 100644 --- a/changedetectionio/tests/fetchers/test_content.py +++ b/changedetectionio/tests/fetchers/test_content.py @@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks import logging # Requires playwright to be installed -def test_fetch_webdriver_content(client, live_server): +def test_fetch_webdriver_content(client, live_server, measure_memory_usage): live_server_setup(live_server) ##################### diff --git a/changedetectionio/tests/fetchers/test_custom_js_before_content.py b/changedetectionio/tests/fetchers/test_custom_js_before_content.py index bec4334a..24d715b3 100644 --- a/changedetectionio/tests/fetchers/test_custom_js_before_content.py +++ b/changedetectionio/tests/fetchers/test_custom_js_before_content.py @@ -3,7 +3,7 @@ from flask import url_for from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client -def test_execute_custom_js(client, live_server): +def test_execute_custom_js(client, live_server, measure_memory_usage): live_server_setup(live_server) assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test" diff --git a/changedetectionio/tests/proxy_list/test_multiple_proxy.py b/changedetectionio/tests/proxy_list/test_multiple_proxy.py index f2e0d1a4..259aa5e8 100644 --- a/changedetectionio/tests/proxy_list/test_multiple_proxy.py +++ b/changedetectionio/tests/proxy_list/test_multiple_proxy.py @@ -5,7 +5,7 @@ from flask import url_for from ..util import live_server_setup, wait_for_all_checks -def test_preferred_proxy(client, live_server): +def test_preferred_proxy(client, live_server, measure_memory_usage): live_server_setup(live_server) url = "http://chosen.changedetection.io" diff --git a/changedetectionio/tests/proxy_list/test_noproxy.py b/changedetectionio/tests/proxy_list/test_noproxy.py index 5a3cbce2..05b8babf 100644 --- a/changedetectionio/tests/proxy_list/test_noproxy.py +++ b/changedetectionio/tests/proxy_list/test_noproxy.py @@ -5,7 +5,7 @@ from flask import url_for from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client -def test_noproxy_option(client, live_server): +def test_noproxy_option(client, live_server, measure_memory_usage): live_server_setup(live_server) # Run by run_proxy_tests.sh # Call this URL then scan the containers that it never went through them diff --git a/changedetectionio/tests/proxy_list/test_proxy.py b/changedetectionio/tests/proxy_list/test_proxy.py index 1f4c5ff4..19bd8a40 100644 --- a/changedetectionio/tests/proxy_list/test_proxy.py +++ b/changedetectionio/tests/proxy_list/test_proxy.py @@ -5,7 +5,7 @@ from flask import url_for from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client # just make a request, we will grep in the docker logs to see it actually got called -def test_check_basic_change_detection_functionality(client, live_server): +def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage): live_server_setup(live_server) res = client.post( url_for("import_page"), diff --git a/changedetectionio/tests/proxy_list/test_select_custom_proxy.py b/changedetectionio/tests/proxy_list/test_select_custom_proxy.py index eb8990d3..4453a628 100644 --- a/changedetectionio/tests/proxy_list/test_select_custom_proxy.py +++ b/changedetectionio/tests/proxy_list/test_select_custom_proxy.py @@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks import os # just make a request, we will grep in the docker logs to see it actually got called -def test_select_custom(client, live_server): +def test_select_custom(client, live_server, measure_memory_usage): live_server_setup(live_server) # Goto settings, add our custom one diff --git a/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py b/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py index 8fb52bf8..e395e785 100644 --- a/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py +++ b/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py @@ -5,7 +5,7 @@ from flask import url_for from changedetectionio.tests.util import live_server_setup, wait_for_all_checks -def test_socks5(client, live_server): +def test_socks5(client, live_server, measure_memory_usage): live_server_setup(live_server) # Setup a proxy diff --git a/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py b/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py index 2562249b..a5c67206 100644 --- a/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py +++ b/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py @@ -7,7 +7,7 @@ from changedetectionio.tests.util import live_server_setup, wait_for_all_checks # should be proxies.json mounted from run_proxy_tests.sh already # -v `pwd`/tests/proxy_socks5/proxies.json-example:/app/changedetectionio/test-datastore/proxies.json -def test_socks5_from_proxiesjson_file(client, live_server): +def test_socks5_from_proxiesjson_file(client, live_server, measure_memory_usage): live_server_setup(live_server) test_url = "https://changedetection.io/CHANGELOG.txt?socks-test-tag=" + os.getenv('SOCKSTEST', '') diff --git a/changedetectionio/tests/restock/test_restock.py b/changedetectionio/tests/restock/test_restock.py index 30528cd1..026f1442 100644 --- a/changedetectionio/tests/restock/test_restock.py +++ b/changedetectionio/tests/restock/test_restock.py @@ -48,7 +48,7 @@ def set_back_in_stock_response(): return None # Add a site in paused mode, add an invalid filter, we should still have visual selector data ready -def test_restock_detection(client, live_server): +def test_restock_detection(client, live_server, measure_memory_usage): set_original_response() #assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test" diff --git a/changedetectionio/tests/smtp/test_notification_smtp.py b/changedetectionio/tests/smtp/test_notification_smtp.py index c69299fe..47080a9a 100644 --- a/changedetectionio/tests/smtp/test_notification_smtp.py +++ b/changedetectionio/tests/smtp/test_notification_smtp.py @@ -40,7 +40,7 @@ def get_last_message_from_smtp_server(): # Requires running the test SMTP server -def test_check_notification_email_formats_default_HTML(client, live_server): +def test_check_notification_email_formats_default_HTML(client, live_server, measure_memory_usage): # live_server_setup(live_server) set_original_response() @@ -92,7 +92,7 @@ def test_check_notification_email_formats_default_HTML(client, live_server): assert b'Deleted' in res.data -def test_check_notification_email_formats_default_Text_override_HTML(client, live_server): +def test_check_notification_email_formats_default_Text_override_HTML(client, live_server, measure_memory_usage): # live_server_setup(live_server) # HTML problems? see this diff --git a/changedetectionio/tests/test_add_replace_remove_filter.py b/changedetectionio/tests/test_add_replace_remove_filter.py index f64d877b..3d6d9f32 100644 --- a/changedetectionio/tests/test_add_replace_remove_filter.py +++ b/changedetectionio/tests/test_add_replace_remove_filter.py @@ -35,10 +35,10 @@ def set_original(excluding=None, add_line=None): with open("test-datastore/endpoint-content.txt", "w") as f: f.write(test_return_data) -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_check_removed_line_contains_trigger(client, live_server): +def test_check_removed_line_contains_trigger(client, live_server, measure_memory_usage): # Give the endpoint time to spin up time.sleep(1) @@ -103,7 +103,7 @@ def test_check_removed_line_contains_trigger(client, live_server): assert b'Deleted' in res.data -def test_check_add_line_contains_trigger(client, live_server): +def test_check_add_line_contains_trigger(client, live_server, measure_memory_usage): #live_server_setup(live_server) # Give the endpoint time to spin up diff --git a/changedetectionio/tests/test_api.py b/changedetectionio/tests/test_api.py index 2f66489a..791e02f9 100644 --- a/changedetectionio/tests/test_api.py +++ b/changedetectionio/tests/test_api.py @@ -53,10 +53,10 @@ def is_valid_uuid(val): return False -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_api_simple(client, live_server): +def test_api_simple(client, live_server, measure_memory_usage): #live_server_setup(live_server) api_key = extract_api_key_from_UI(client) @@ -241,7 +241,7 @@ def test_api_simple(client, live_server): ) assert len(res.json) == 0, "Watch list should be empty" -def test_access_denied(client, live_server): +def test_access_denied(client, live_server, measure_memory_usage): # `config_api_token_enabled` Should be On by default res = client.get( url_for("createwatch") @@ -287,7 +287,7 @@ def test_access_denied(client, live_server): ) assert b"Settings updated." in res.data -def test_api_watch_PUT_update(client, live_server): +def test_api_watch_PUT_update(client, live_server, measure_memory_usage): #live_server_setup(live_server) api_key = extract_api_key_from_UI(client) @@ -369,7 +369,7 @@ def test_api_watch_PUT_update(client, live_server): assert b'Deleted' in res.data -def test_api_import(client, live_server): +def test_api_import(client, live_server, measure_memory_usage): api_key = extract_api_key_from_UI(client) res = client.post( diff --git a/changedetectionio/tests/test_auth.py b/changedetectionio/tests/test_auth.py index be817ba4..3406dc7b 100644 --- a/changedetectionio/tests/test_auth.py +++ b/changedetectionio/tests/test_auth.py @@ -5,7 +5,7 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_basic_auth(client, live_server): +def test_basic_auth(client, live_server, measure_memory_usage): live_server_setup(live_server) diff --git a/changedetectionio/tests/test_automatic_follow_ldjson_price.py b/changedetectionio/tests/test_automatic_follow_ldjson_price.py index c589ea25..d09fbf05 100644 --- a/changedetectionio/tests/test_automatic_follow_ldjson_price.py +++ b/changedetectionio/tests/test_automatic_follow_ldjson_price.py @@ -76,11 +76,11 @@ def set_response_without_ldjson(): f.write(test_return_data) return None -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) # actually only really used by the distll.io importer, but could be handy too -def test_check_ldjson_price_autodetect(client, live_server): +def test_check_ldjson_price_autodetect(client, live_server, measure_memory_usage): set_response_with_ldjson() @@ -167,7 +167,7 @@ def _test_runner_check_bad_format_ignored(live_server, client, has_ldjson_price_ client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_bad_ldjson_is_correctly_ignored(client, live_server): +def test_bad_ldjson_is_correctly_ignored(client, live_server, measure_memory_usage): #live_server_setup(live_server) test_return_data = """ diff --git a/changedetectionio/tests/test_backend.py b/changedetectionio/tests/test_backend.py index a6f735b5..f7cea925 100644 --- a/changedetectionio/tests/test_backend.py +++ b/changedetectionio/tests/test_backend.py @@ -17,7 +17,7 @@ def test_inscriptus(): assert stripped_text_from_html == 'test!\nok man' -def test_check_basic_change_detection_functionality(client, live_server): +def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage): set_original_response() live_server_setup(live_server) diff --git a/changedetectionio/tests/test_backup.py b/changedetectionio/tests/test_backup.py index 9f381755..650981ad 100644 --- a/changedetectionio/tests/test_backup.py +++ b/changedetectionio/tests/test_backup.py @@ -8,7 +8,7 @@ import re import time -def test_backup(client, live_server): +def test_backup(client, live_server, measure_memory_usage): live_server_setup(live_server) set_original_response() diff --git a/changedetectionio/tests/test_block_while_text_present.py b/changedetectionio/tests/test_block_while_text_present.py index 2669b52a..9d966492 100644 --- a/changedetectionio/tests/test_block_while_text_present.py +++ b/changedetectionio/tests/test_block_while_text_present.py @@ -60,7 +60,7 @@ def set_modified_response_minus_block_text(): f.write(test_return_data) -def test_check_block_changedetection_text_NOT_present(client, live_server): +def test_check_block_changedetection_text_NOT_present(client, live_server, measure_memory_usage): live_server_setup(live_server) # Use a mix of case in ZzZ to prove it works case-insensitive. diff --git a/changedetectionio/tests/test_clone.py b/changedetectionio/tests/test_clone.py index 7f502be1..3dd81c2b 100644 --- a/changedetectionio/tests/test_clone.py +++ b/changedetectionio/tests/test_clone.py @@ -6,7 +6,7 @@ from . util import live_server_setup -def test_trigger_functionality(client, live_server): +def test_trigger_functionality(client, live_server, measure_memory_usage): live_server_setup(live_server) diff --git a/changedetectionio/tests/test_css_selector.py b/changedetectionio/tests/test_css_selector.py index dcc10331..cc0aa86f 100644 --- a/changedetectionio/tests/test_css_selector.py +++ b/changedetectionio/tests/test_css_selector.py @@ -70,7 +70,7 @@ def test_include_filters_output(): # Tests the whole stack works with the CSS Filter -def test_check_markup_include_filters_restriction(client, live_server): +def test_check_markup_include_filters_restriction(client, live_server, measure_memory_usage): sleep_time_for_fetch_thread = 3 include_filters = "#sametext" @@ -124,7 +124,7 @@ def test_check_markup_include_filters_restriction(client, live_server): # Tests the whole stack works with the CSS Filter -def test_check_multiple_filters(client, live_server): +def test_check_multiple_filters(client, live_server, measure_memory_usage): sleep_time_for_fetch_thread = 3 include_filters = "#blob-a\r\nxpath://*[contains(@id,'blob-b')]" @@ -180,7 +180,7 @@ def test_check_multiple_filters(client, live_server): # The filter exists, but did not contain anything useful # Mainly used when the filter contains just an IMG, this can happen when someone selects an image in the visual-selector # Tests fetcher can throw a "ReplyWithContentButNoText" exception after applying filter and extracting text -def test_filter_is_empty_help_suggestion(client, live_server): +def test_filter_is_empty_help_suggestion(client, live_server, measure_memory_usage): #live_server_setup(live_server) include_filters = "#blob-a" diff --git a/changedetectionio/tests/test_element_removal.py b/changedetectionio/tests/test_element_removal.py index 3c280d22..39d5a03a 100644 --- a/changedetectionio/tests/test_element_removal.py +++ b/changedetectionio/tests/test_element_removal.py @@ -106,7 +106,7 @@ across multiple lines ) -def test_element_removal_full(client, live_server): +def test_element_removal_full(client, live_server, measure_memory_usage): sleep_time_for_fetch_thread = 3 set_original_response() diff --git a/changedetectionio/tests/test_encoding.py b/changedetectionio/tests/test_encoding.py index c00a28b8..c065748a 100644 --- a/changedetectionio/tests/test_encoding.py +++ b/changedetectionio/tests/test_encoding.py @@ -24,7 +24,7 @@ def set_html_response(): # In the case the server does not issue a charset= or doesnt have content_type header set -def test_check_encoding_detection(client, live_server): +def test_check_encoding_detection(client, live_server, measure_memory_usage): set_html_response() # Add our URL to the import page @@ -50,7 +50,7 @@ def test_check_encoding_detection(client, live_server): # In the case the server does not issue a charset= or doesnt have content_type header set -def test_check_encoding_detection_missing_content_type_header(client, live_server): +def test_check_encoding_detection_missing_content_type_header(client, live_server, measure_memory_usage): set_html_response() # Add our URL to the import page diff --git a/changedetectionio/tests/test_errorhandling.py b/changedetectionio/tests/test_errorhandling.py index d439fee1..6ce8bfc7 100644 --- a/changedetectionio/tests/test_errorhandling.py +++ b/changedetectionio/tests/test_errorhandling.py @@ -54,7 +54,7 @@ def _runner_test_http_errors(client, live_server, http_code, expected_text): assert b'Deleted' in res.data -def test_http_error_handler(client, live_server): +def test_http_error_handler(client, live_server, measure_memory_usage): _runner_test_http_errors(client, live_server, 403, 'Access denied') _runner_test_http_errors(client, live_server, 404, 'Page not found') _runner_test_http_errors(client, live_server, 500, '(Internal server error) received') @@ -63,7 +63,7 @@ def test_http_error_handler(client, live_server): assert b'Deleted' in res.data # Just to be sure error text is properly handled -def test_DNS_errors(client, live_server): +def test_DNS_errors(client, live_server, measure_memory_usage): # Give the endpoint time to spin up time.sleep(1) @@ -87,7 +87,7 @@ def test_DNS_errors(client, live_server): assert b'Deleted' in res.data # Re 1513 -def test_low_level_errors_clear_correctly(client, live_server): +def test_low_level_errors_clear_correctly(client, live_server, measure_memory_usage): #live_server_setup(live_server) # Give the endpoint time to spin up time.sleep(1) diff --git a/changedetectionio/tests/test_extract_csv.py b/changedetectionio/tests/test_extract_csv.py index 7fcc83c4..9937fbba 100644 --- a/changedetectionio/tests/test_extract_csv.py +++ b/changedetectionio/tests/test_extract_csv.py @@ -9,7 +9,7 @@ sleep_time_for_fetch_thread = 3 -def test_check_extract_text_from_diff(client, live_server): +def test_check_extract_text_from_diff(client, live_server, measure_memory_usage): import time with open("test-datastore/endpoint-content.txt", "w") as f: f.write("Now it's {} seconds since epoch, time flies!".format(str(time.time()))) diff --git a/changedetectionio/tests/test_extract_regex.py b/changedetectionio/tests/test_extract_regex.py index 45a84800..eb9cf0ff 100644 --- a/changedetectionio/tests/test_extract_regex.py +++ b/changedetectionio/tests/test_extract_regex.py @@ -67,10 +67,10 @@ def set_multiline_response(): return None -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_check_filter_multiline(client, live_server): +def test_check_filter_multiline(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_multiline_response() @@ -122,7 +122,7 @@ def test_check_filter_multiline(client, live_server): # but the last one, which also says 'lines' shouldnt be here (non-greedy match checking) assert b'aaand something lines' not in res.data -def test_check_filter_and_regex_extract(client, live_server): +def test_check_filter_and_regex_extract(client, live_server, measure_memory_usage): include_filters = ".changetext" @@ -205,7 +205,7 @@ def test_check_filter_and_regex_extract(client, live_server): -def test_regex_error_handling(client, live_server): +def test_regex_error_handling(client, live_server, measure_memory_usage): #live_server_setup(live_server) diff --git a/changedetectionio/tests/test_filter_exist_changes.py b/changedetectionio/tests/test_filter_exist_changes.py index e57db579..2deaf5c6 100644 --- a/changedetectionio/tests/test_filter_exist_changes.py +++ b/changedetectionio/tests/test_filter_exist_changes.py @@ -41,7 +41,7 @@ def set_response_with_filter(): f.write(test_return_data) return None -def test_filter_doesnt_exist_then_exists_should_get_notification(client, live_server): +def test_filter_doesnt_exist_then_exists_should_get_notification(client, live_server, measure_memory_usage): # Filter knowingly doesn't exist, like someone setting up a known filter to see if some cinema tickets are on sale again # And the page has that filter available # Then I should get a notification diff --git a/changedetectionio/tests/test_filter_failure_notification.py b/changedetectionio/tests/test_filter_failure_notification.py index 6d4c3154..0cc8711d 100644 --- a/changedetectionio/tests/test_filter_failure_notification.py +++ b/changedetectionio/tests/test_filter_failure_notification.py @@ -151,10 +151,10 @@ def run_filter_test(client, live_server, content_filter): def test_setup(live_server): live_server_setup(live_server) -def test_check_include_filters_failure_notification(client, live_server): +def test_check_include_filters_failure_notification(client, live_server, measure_memory_usage): run_filter_test(client, live_server,'#nope-doesnt-exist') -def test_check_xpath_filter_failure_notification(client, live_server): +def test_check_xpath_filter_failure_notification(client, live_server, measure_memory_usage): run_filter_test(client, live_server, '//*[@id="nope-doesnt-exist"]') # Test that notification is never sent diff --git a/changedetectionio/tests/test_group.py b/changedetectionio/tests/test_group.py index 8904097d..b54345f7 100644 --- a/changedetectionio/tests/test_group.py +++ b/changedetectionio/tests/test_group.py @@ -6,7 +6,7 @@ from .util import live_server_setup, wait_for_all_checks, extract_rss_token_from import os -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) def set_original_response(): @@ -39,7 +39,7 @@ def set_modified_response(): f.write(test_return_data) return None -def test_setup_group_tag(client, live_server): +def test_setup_group_tag(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_original_response() @@ -130,7 +130,7 @@ def test_setup_group_tag(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_tag_import_singular(client, live_server): +def test_tag_import_singular(client, live_server, measure_memory_usage): #live_server_setup(live_server) test_url = url_for('test_endpoint', _external=True) @@ -150,7 +150,7 @@ def test_tag_import_singular(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_tag_add_in_ui(client, live_server): +def test_tag_add_in_ui(client, live_server, measure_memory_usage): #live_server_setup(live_server) # res = client.post( @@ -167,7 +167,7 @@ def test_tag_add_in_ui(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_group_tag_notification(client, live_server): +def test_group_tag_notification(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_original_response() @@ -235,7 +235,7 @@ def test_group_tag_notification(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_limit_tag_ui(client, live_server): +def test_limit_tag_ui(client, live_server, measure_memory_usage): #live_server_setup(live_server) test_url = url_for('test_endpoint', _external=True) @@ -273,7 +273,7 @@ def test_limit_tag_ui(client, live_server): assert b'Deleted' in res.data res = client.get(url_for("tags.delete_all"), follow_redirects=True) assert b'All tags deleted' in res.data -def test_clone_tag_on_import(client, live_server): +def test_clone_tag_on_import(client, live_server, measure_memory_usage): #live_server_setup(live_server) test_url = url_for('test_endpoint', _external=True) res = client.post( @@ -298,7 +298,7 @@ def test_clone_tag_on_import(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_clone_tag_on_quickwatchform_add(client, live_server): +def test_clone_tag_on_quickwatchform_add(client, live_server, measure_memory_usage): #live_server_setup(live_server) test_url = url_for('test_endpoint', _external=True) @@ -328,7 +328,7 @@ def test_clone_tag_on_quickwatchform_add(client, live_server): res = client.get(url_for("tags.delete_all"), follow_redirects=True) assert b'All tags deleted' in res.data -def test_order_of_filters_tag_filter_and_watch_filter(client, live_server): +def test_order_of_filters_tag_filter_and_watch_filter(client, live_server, measure_memory_usage): # Add a tag with some config, import a tag and it should roughly work res = client.post( diff --git a/changedetectionio/tests/test_history_consistency.py b/changedetectionio/tests/test_history_consistency.py index c20aa34b..b31004ea 100644 --- a/changedetectionio/tests/test_history_consistency.py +++ b/changedetectionio/tests/test_history_consistency.py @@ -8,7 +8,7 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks from urllib.parse import urlparse, parse_qs -def test_consistent_history(client, live_server): +def test_consistent_history(client, live_server, measure_memory_usage): live_server_setup(live_server) r = range(1, 30) diff --git a/changedetectionio/tests/test_ignore_text.py b/changedetectionio/tests/test_ignore_text.py index 5d6d7149..dd643ddf 100644 --- a/changedetectionio/tests/test_ignore_text.py +++ b/changedetectionio/tests/test_ignore_text.py @@ -82,7 +82,7 @@ def set_modified_ignore_response(): f.write(test_return_data) -def test_check_ignore_text_functionality(client, live_server): +def test_check_ignore_text_functionality(client, live_server, measure_memory_usage): # Use a mix of case in ZzZ to prove it works case-insensitive. ignore_text = "XXXXX\r\nYYYYY\r\nzZzZZ\r\nnew ignore stuff" @@ -164,7 +164,7 @@ def test_check_ignore_text_functionality(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_check_global_ignore_text_functionality(client, live_server): +def test_check_global_ignore_text_functionality(client, live_server, measure_memory_usage): # Give the endpoint time to spin up time.sleep(1) diff --git a/changedetectionio/tests/test_ignorehighlighter.py b/changedetectionio/tests/test_ignorehighlighter.py index 52163845..3a1277d9 100644 --- a/changedetectionio/tests/test_ignorehighlighter.py +++ b/changedetectionio/tests/test_ignorehighlighter.py @@ -23,7 +23,7 @@ def set_original_ignore_response(): f.write(test_return_data) -def test_highlight_ignore(client, live_server): +def test_highlight_ignore(client, live_server, measure_memory_usage): live_server_setup(live_server) set_original_ignore_response() test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_ignorehyperlinks.py b/changedetectionio/tests/test_ignorehyperlinks.py index f917125f..0492b5cc 100644 --- a/changedetectionio/tests/test_ignorehyperlinks.py +++ b/changedetectionio/tests/test_ignorehyperlinks.py @@ -40,7 +40,7 @@ def set_modified_ignore_response(): with open("test-datastore/endpoint-content.txt", "w") as f: f.write(test_return_data) -def test_render_anchor_tag_content_true(client, live_server): +def test_render_anchor_tag_content_true(client, live_server, measure_memory_usage): """Testing that the link changes are detected when render_anchor_tag_content setting is set to true""" sleep_time_for_fetch_thread = 3 diff --git a/changedetectionio/tests/test_ignorestatuscode.py b/changedetectionio/tests/test_ignorestatuscode.py index 74999b24..bc9ad810 100644 --- a/changedetectionio/tests/test_ignorestatuscode.py +++ b/changedetectionio/tests/test_ignorestatuscode.py @@ -39,7 +39,7 @@ def set_some_changed_response(): f.write(test_return_data) -def test_normal_page_check_works_with_ignore_status_code(client, live_server): +def test_normal_page_check_works_with_ignore_status_code(client, live_server, measure_memory_usage): # Give the endpoint time to spin up @@ -85,7 +85,7 @@ def test_normal_page_check_works_with_ignore_status_code(client, live_server): # Tests the whole stack works with staus codes ignored -def test_403_page_check_works_with_ignore_status_code(client, live_server): +def test_403_page_check_works_with_ignore_status_code(client, live_server, measure_memory_usage): sleep_time_for_fetch_thread = 3 set_original_response() diff --git a/changedetectionio/tests/test_ignorewhitespace.py b/changedetectionio/tests/test_ignorewhitespace.py index a0db9ead..2c4e3c72 100644 --- a/changedetectionio/tests/test_ignorewhitespace.py +++ b/changedetectionio/tests/test_ignorewhitespace.py @@ -49,7 +49,7 @@ def set_original_ignore_response(): # If there was only a change in the whitespacing, then we shouldnt have a change detected -def test_check_ignore_whitespace(client, live_server): +def test_check_ignore_whitespace(client, live_server, measure_memory_usage): sleep_time_for_fetch_thread = 3 # Give the endpoint time to spin up diff --git a/changedetectionio/tests/test_import.py b/changedetectionio/tests/test_import.py index ed080e0e..dc7b58eb 100644 --- a/changedetectionio/tests/test_import.py +++ b/changedetectionio/tests/test_import.py @@ -8,10 +8,10 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_import(client, live_server): +def test_import(client, live_server, measure_memory_usage): # Give the endpoint time to spin up wait_for_all_checks(client) @@ -34,7 +34,7 @@ https://example.com tag1, other tag""" res = client.get( url_for("index")) res = client.get( url_for("index")) -def xtest_import_skip_url(client, live_server): +def xtest_import_skip_url(client, live_server, measure_memory_usage): # Give the endpoint time to spin up @@ -57,7 +57,7 @@ def xtest_import_skip_url(client, live_server): # Clear flask alerts res = client.get( url_for("index")) -def test_import_distillio(client, live_server): +def test_import_distillio(client, live_server, measure_memory_usage): distill_data=''' { @@ -123,7 +123,7 @@ def test_import_distillio(client, live_server): # Clear flask alerts res = client.get(url_for("index")) -def test_import_custom_xlsx(client, live_server): +def test_import_custom_xlsx(client, live_server, measure_memory_usage): """Test can upload a excel spreadsheet and the watches are created correctly""" #live_server_setup(live_server) @@ -172,7 +172,7 @@ def test_import_custom_xlsx(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_import_watchete_xlsx(client, live_server): +def test_import_watchete_xlsx(client, live_server, measure_memory_usage): """Test can upload a excel spreadsheet and the watches are created correctly""" #live_server_setup(live_server) diff --git a/changedetectionio/tests/test_jinja2.py b/changedetectionio/tests/test_jinja2.py index 1e08691b..096310ec 100644 --- a/changedetectionio/tests/test_jinja2.py +++ b/changedetectionio/tests/test_jinja2.py @@ -5,11 +5,11 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) # If there was only a change in the whitespacing, then we shouldnt have a change detected -def test_jinja2_in_url_query(client, live_server): +def test_jinja2_in_url_query(client, live_server, measure_memory_usage): #live_server_setup(live_server) # Add our URL to the import page @@ -34,7 +34,7 @@ def test_jinja2_in_url_query(client, live_server): assert b'date=2' in res.data # https://techtonics.medium.com/secure-templating-with-jinja2-understanding-ssti-and-jinja2-sandbox-environment-b956edd60456 -def test_jinja2_security_url_query(client, live_server): +def test_jinja2_security_url_query(client, live_server, measure_memory_usage): #live_server_setup(live_server) # Add our URL to the import page diff --git a/changedetectionio/tests/test_jsonpath_jq_selector.py b/changedetectionio/tests/test_jsonpath_jq_selector.py index 55f46a0d..6b510c10 100644 --- a/changedetectionio/tests/test_jsonpath_jq_selector.py +++ b/changedetectionio/tests/test_jsonpath_jq_selector.py @@ -201,7 +201,7 @@ def set_modified_response(): return None -def test_check_json_without_filter(client, live_server): +def test_check_json_without_filter(client, live_server, measure_memory_usage): # Request a JSON document from a application/json source containing HTML # and be sure it doesn't get chewed up by instriptis set_json_response_with_html() @@ -294,14 +294,14 @@ def check_json_filter(json_filter, client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_check_jsonpath_filter(client, live_server): +def test_check_jsonpath_filter(client, live_server, measure_memory_usage): check_json_filter('json:boss.name', client, live_server) -def test_check_jq_filter(client, live_server): +def test_check_jq_filter(client, live_server, measure_memory_usage): if jq_support: check_json_filter('jq:.boss.name', client, live_server) -def test_check_jqraw_filter(client, live_server): +def test_check_jqraw_filter(client, live_server, measure_memory_usage): if jq_support: check_json_filter('jqraw:.boss.name', client, live_server) @@ -352,14 +352,14 @@ def check_json_filter_bool_val(json_filter, client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_check_jsonpath_filter_bool_val(client, live_server): +def test_check_jsonpath_filter_bool_val(client, live_server, measure_memory_usage): check_json_filter_bool_val("json:$['available']", client, live_server) -def test_check_jq_filter_bool_val(client, live_server): +def test_check_jq_filter_bool_val(client, live_server, measure_memory_usage): if jq_support: check_json_filter_bool_val("jq:.available", client, live_server) -def test_check_jqraw_filter_bool_val(client, live_server): +def test_check_jqraw_filter_bool_val(client, live_server, measure_memory_usage): if jq_support: check_json_filter_bool_val("jq:.available", client, live_server) @@ -430,7 +430,7 @@ def check_json_ext_filter(json_filter, client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_ignore_json_order(client, live_server): +def test_ignore_json_order(client, live_server, measure_memory_usage): # A change in order shouldn't trigger a notification with open("test-datastore/endpoint-content.txt", "w") as f: @@ -472,7 +472,7 @@ def test_ignore_json_order(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_correct_header_detect(client, live_server): +def test_correct_header_detect(client, live_server, measure_memory_usage): # Like in https://github.com/dgtlmoon/changedetection.io/pull/1593 # Specify extra html that JSON is sometimes wrapped in - when using SockpuppetBrowser / Puppeteer / Playwrightetc with open("test-datastore/endpoint-content.txt", "w") as f: @@ -504,13 +504,13 @@ def test_correct_header_detect(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_check_jsonpath_ext_filter(client, live_server): +def test_check_jsonpath_ext_filter(client, live_server, measure_memory_usage): check_json_ext_filter('json:$[?(@.status==Sold)]', client, live_server) -def test_check_jq_ext_filter(client, live_server): +def test_check_jq_ext_filter(client, live_server, measure_memory_usage): if jq_support: check_json_ext_filter('jq:.[] | select(.status | contains("Sold"))', client, live_server) -def test_check_jqraw_ext_filter(client, live_server): +def test_check_jqraw_ext_filter(client, live_server, measure_memory_usage): if jq_support: check_json_ext_filter('jq:.[] | select(.status | contains("Sold"))', client, live_server) diff --git a/changedetectionio/tests/test_nonrenderable_pages.py b/changedetectionio/tests/test_nonrenderable_pages.py index e4eec1f8..23ce3563 100644 --- a/changedetectionio/tests/test_nonrenderable_pages.py +++ b/changedetectionio/tests/test_nonrenderable_pages.py @@ -22,7 +22,7 @@ def set_nonrenderable_response(): return None -def test_check_basic_change_detection_functionality(client, live_server): +def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage): set_original_response() live_server_setup(live_server) diff --git a/changedetectionio/tests/test_notification.py b/changedetectionio/tests/test_notification.py index 3c6674f8..a83316be 100644 --- a/changedetectionio/tests/test_notification.py +++ b/changedetectionio/tests/test_notification.py @@ -21,7 +21,7 @@ def test_setup(live_server): # Hard to just add more live server URLs when one test is already running (I think) # So we add our test here (was in a different file) -def test_check_notification(client, live_server): +def test_check_notification(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_original_response() @@ -234,7 +234,7 @@ def test_check_notification(client, live_server): follow_redirects=True ) -def test_notification_validation(client, live_server): +def test_notification_validation(client, live_server, measure_memory_usage): time.sleep(1) @@ -273,7 +273,7 @@ def test_notification_validation(client, live_server): -def test_notification_custom_endpoint_and_jinja2(client, live_server): +def test_notification_custom_endpoint_and_jinja2(client, live_server, measure_memory_usage): #live_server_setup(live_server) # test_endpoint - that sends the contents of a file diff --git a/changedetectionio/tests/test_notification_errors.py b/changedetectionio/tests/test_notification_errors.py index 21eb21c6..206b8f7e 100644 --- a/changedetectionio/tests/test_notification_errors.py +++ b/changedetectionio/tests/test_notification_errors.py @@ -4,7 +4,7 @@ from flask import url_for from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks import logging -def test_check_notification_error_handling(client, live_server): +def test_check_notification_error_handling(client, live_server, measure_memory_usage): live_server_setup(live_server) set_original_response() diff --git a/changedetectionio/tests/test_obfuscations.py b/changedetectionio/tests/test_obfuscations.py index 17956744..1d8519b4 100644 --- a/changedetectionio/tests/test_obfuscations.py +++ b/changedetectionio/tests/test_obfuscations.py @@ -18,7 +18,7 @@ def set_original_ignore_response(): f.write(test_return_data) -def test_obfuscations(client, live_server): +def test_obfuscations(client, live_server, measure_memory_usage): set_original_ignore_response() live_server_setup(live_server) time.sleep(1) diff --git a/changedetectionio/tests/test_pdf.py b/changedetectionio/tests/test_pdf.py index 2d4fb6a9..746f34db 100644 --- a/changedetectionio/tests/test_pdf.py +++ b/changedetectionio/tests/test_pdf.py @@ -6,7 +6,7 @@ from .util import set_original_response, set_modified_response, live_server_setu # `subtractive_selectors` should still work in `source:` type requests -def test_fetch_pdf(client, live_server): +def test_fetch_pdf(client, live_server, measure_memory_usage): import shutil shutil.copy("tests/test.pdf", "test-datastore/endpoint-test.pdf") diff --git a/changedetectionio/tests/test_request.py b/changedetectionio/tests/test_request.py index 1ec501fe..402ab7ad 100644 --- a/changedetectionio/tests/test_request.py +++ b/changedetectionio/tests/test_request.py @@ -9,7 +9,7 @@ def test_setup(live_server): # Hard to just add more live server URLs when one test is already running (I think) # So we add our test here (was in a different file) -def test_headers_in_request(client, live_server): +def test_headers_in_request(client, live_server, measure_memory_usage): #ve_server_setup(live_server) # Add our URL to the import page test_url = url_for('test_headers', _external=True) @@ -84,7 +84,7 @@ def test_headers_in_request(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_body_in_request(client, live_server): +def test_body_in_request(client, live_server, measure_memory_usage): # Add our URL to the import page test_url = url_for('test_body', _external=True) @@ -177,7 +177,7 @@ def test_body_in_request(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_method_in_request(client, live_server): +def test_method_in_request(client, live_server, measure_memory_usage): # Add our URL to the import page test_url = url_for('test_method', _external=True) if os.getenv('PLAYWRIGHT_DRIVER_URL'): @@ -254,7 +254,7 @@ def test_method_in_request(client, live_server): assert b'Deleted' in res.data # Re #2408 - user-agent override test, also should handle case-insensitive header deduplication -def test_ua_global_override(client, live_server): +def test_ua_global_override(client, live_server, measure_memory_usage): # live_server_setup(live_server) test_url = url_for('test_headers', _external=True) @@ -309,7 +309,7 @@ def test_ua_global_override(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_headers_textfile_in_request(client, live_server): +def test_headers_textfile_in_request(client, live_server, measure_memory_usage): #live_server_setup(live_server) # Add our URL to the import page diff --git a/changedetectionio/tests/test_rss.py b/changedetectionio/tests/test_rss.py index 8fe2e84d..0456fab7 100644 --- a/changedetectionio/tests/test_rss.py +++ b/changedetectionio/tests/test_rss.py @@ -49,10 +49,10 @@ def set_original_cdata_xml(): f.write(test_return_data) -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_rss_and_token(client, live_server): +def test_rss_and_token(client, live_server, measure_memory_usage): # live_server_setup(live_server) set_original_response() @@ -90,7 +90,7 @@ def test_rss_and_token(client, live_server): client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_basic_cdata_rss_markup(client, live_server): +def test_basic_cdata_rss_markup(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_original_cdata_xml() @@ -118,7 +118,7 @@ def test_basic_cdata_rss_markup(client, live_server): assert b'The days of Terminator' in res.data res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_rss_xpath_filtering(client, live_server): +def test_rss_xpath_filtering(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_original_cdata_xml() diff --git a/changedetectionio/tests/test_search.py b/changedetectionio/tests/test_search.py index 453a0b8a..70dab62f 100644 --- a/changedetectionio/tests/test_search.py +++ b/changedetectionio/tests/test_search.py @@ -5,7 +5,7 @@ import time def test_setup(live_server): live_server_setup(live_server) -def test_basic_search(client, live_server): +def test_basic_search(client, live_server, measure_memory_usage): #live_server_setup(live_server) urls = ['https://localhost:12300?first-result=1', @@ -38,7 +38,7 @@ def test_basic_search(client, live_server): assert urls[1].encode('utf-8') not in res.data -def test_search_in_tag_limit(client, live_server): +def test_search_in_tag_limit(client, live_server, measure_memory_usage): #live_server_setup(live_server) urls = ['https://localhost:12300?first-result=1 tag-one', diff --git a/changedetectionio/tests/test_security.py b/changedetectionio/tests/test_security.py index c56c84492..0b2ee7dc 100644 --- a/changedetectionio/tests/test_security.py +++ b/changedetectionio/tests/test_security.py @@ -2,10 +2,10 @@ from flask import url_for from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks import time -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_bad_access(client, live_server): +def test_bad_access(client, live_server, measure_memory_usage): #live_server_setup(live_server) res = client.post( url_for("import_page"), @@ -67,7 +67,7 @@ def test_bad_access(client, live_server): assert b'file:// type access is denied for security reasons.' in res.data -def test_xss(client, live_server): +def test_xss(client, live_server, measure_memory_usage): #live_server_setup(live_server) from changedetectionio.notification import ( default_notification_format diff --git a/changedetectionio/tests/test_share_watch.py b/changedetectionio/tests/test_share_watch.py index bf76fabc..968eb74b 100644 --- a/changedetectionio/tests/test_share_watch.py +++ b/changedetectionio/tests/test_share_watch.py @@ -9,7 +9,7 @@ import re sleep_time_for_fetch_thread = 3 -def test_share_watch(client, live_server): +def test_share_watch(client, live_server, measure_memory_usage): set_original_response() live_server_setup(live_server) diff --git a/changedetectionio/tests/test_source.py b/changedetectionio/tests/test_source.py index f46e8ad8..fc6834d6 100644 --- a/changedetectionio/tests/test_source.py +++ b/changedetectionio/tests/test_source.py @@ -10,7 +10,7 @@ sleep_time_for_fetch_thread = 3 def test_setup(live_server): live_server_setup(live_server) -def test_check_basic_change_detection_functionality_source(client, live_server): +def test_check_basic_change_detection_functionality_source(client, live_server, measure_memory_usage): set_original_response() test_url = 'source:'+url_for('test_endpoint', _external=True) # Add our URL to the import page @@ -58,7 +58,7 @@ def test_check_basic_change_detection_functionality_source(client, live_server): # `subtractive_selectors` should still work in `source:` type requests -def test_check_ignore_elements(client, live_server): +def test_check_ignore_elements(client, live_server, measure_memory_usage): set_original_response() time.sleep(1) test_url = 'source:'+url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_trigger.py b/changedetectionio/tests/test_trigger.py index 24e9fabf..bd6708ee 100644 --- a/changedetectionio/tests/test_trigger.py +++ b/changedetectionio/tests/test_trigger.py @@ -55,7 +55,7 @@ def set_modified_with_trigger_text_response(): f.write(test_return_data) -def test_trigger_functionality(client, live_server): +def test_trigger_functionality(client, live_server, measure_memory_usage): live_server_setup(live_server) diff --git a/changedetectionio/tests/test_trigger_regex.py b/changedetectionio/tests/test_trigger_regex.py index 7f070e89..8332bb8c 100644 --- a/changedetectionio/tests/test_trigger_regex.py +++ b/changedetectionio/tests/test_trigger_regex.py @@ -22,7 +22,7 @@ def set_original_ignore_response(): -def test_trigger_regex_functionality(client, live_server): +def test_trigger_regex_functionality(client, live_server, measure_memory_usage): live_server_setup(live_server) diff --git a/changedetectionio/tests/test_trigger_regex_with_filter.py b/changedetectionio/tests/test_trigger_regex_with_filter.py index 4f3328fc..b7d8e661 100644 --- a/changedetectionio/tests/test_trigger_regex_with_filter.py +++ b/changedetectionio/tests/test_trigger_regex_with_filter.py @@ -22,7 +22,7 @@ def set_original_ignore_response(): -def test_trigger_regex_functionality_with_filter(client, live_server): +def test_trigger_regex_functionality_with_filter(client, live_server, measure_memory_usage): live_server_setup(live_server) sleep_time_for_fetch_thread = 3 diff --git a/changedetectionio/tests/test_unique_lines.py b/changedetectionio/tests/test_unique_lines.py index 4eff11fd..243f3087 100644 --- a/changedetectionio/tests/test_unique_lines.py +++ b/changedetectionio/tests/test_unique_lines.py @@ -66,10 +66,10 @@ def set_modified_with_trigger_text_response(): with open("test-datastore/endpoint-content.txt", "w") as f: f.write(test_return_data) -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) -def test_unique_lines_functionality(client, live_server): +def test_unique_lines_functionality(client, live_server, measure_memory_usage): #live_server_setup(live_server) @@ -118,7 +118,7 @@ def test_unique_lines_functionality(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_sort_lines_functionality(client, live_server): +def test_sort_lines_functionality(client, live_server, measure_memory_usage): #live_server_setup(live_server) set_modified_swapped_lines_with_extra_text_for_sorting() diff --git a/changedetectionio/tests/test_watch_fields_storage.py b/changedetectionio/tests/test_watch_fields_storage.py index 7dc3f748..5737c9c7 100644 --- a/changedetectionio/tests/test_watch_fields_storage.py +++ b/changedetectionio/tests/test_watch_fields_storage.py @@ -4,7 +4,7 @@ from urllib.request import urlopen from . util import set_original_response, set_modified_response, live_server_setup -def test_check_watch_field_storage(client, live_server): +def test_check_watch_field_storage(client, live_server, measure_memory_usage): set_original_response() live_server_setup(live_server) diff --git a/changedetectionio/tests/test_xpath_selector.py b/changedetectionio/tests/test_xpath_selector.py index 1a9c5afa..e8b5d855 100644 --- a/changedetectionio/tests/test_xpath_selector.py +++ b/changedetectionio/tests/test_xpath_selector.py @@ -49,7 +49,7 @@ def set_modified_response(): # Handle utf-8 charset replies https://github.com/dgtlmoon/changedetection.io/pull/613 -def test_check_xpath_filter_utf8(client, live_server): +def test_check_xpath_filter_utf8(client, live_server, measure_memory_usage): filter = '//item/*[self::description]' d = ''' @@ -105,7 +105,7 @@ def test_check_xpath_filter_utf8(client, live_server): # Handle utf-8 charset replies https://github.com/dgtlmoon/changedetection.io/pull/613 -def test_check_xpath_text_function_utf8(client, live_server): +def test_check_xpath_text_function_utf8(client, live_server, measure_memory_usage): filter = '//item/title/text()' d = ''' @@ -168,7 +168,7 @@ def test_check_xpath_text_function_utf8(client, live_server): assert b'Deleted' in res.data -def test_check_markup_xpath_filter_restriction(client, live_server): +def test_check_markup_xpath_filter_restriction(client, live_server, measure_memory_usage): xpath_filter = "//*[contains(@class, 'sametext')]" set_original_response() @@ -214,7 +214,7 @@ def test_check_markup_xpath_filter_restriction(client, live_server): assert b'Deleted' in res.data -def test_xpath_validation(client, live_server): +def test_xpath_validation(client, live_server, measure_memory_usage): # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) res = client.post( @@ -235,7 +235,7 @@ def test_xpath_validation(client, live_server): assert b'Deleted' in res.data -def test_xpath23_prefix_validation(client, live_server): +def test_xpath23_prefix_validation(client, live_server, measure_memory_usage): # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) res = client.post( @@ -255,7 +255,7 @@ def test_xpath23_prefix_validation(client, live_server): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data -def test_xpath1_lxml(client, live_server): +def test_xpath1_lxml(client, live_server, measure_memory_usage): #live_server_setup(live_server) d = ''' @@ -319,7 +319,7 @@ def test_xpath1_lxml(client, live_server): ##### -def test_xpath1_validation(client, live_server): +def test_xpath1_validation(client, live_server, measure_memory_usage): # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) res = client.post( @@ -341,7 +341,7 @@ def test_xpath1_validation(client, live_server): # actually only really used by the distll.io importer, but could be handy too -def test_check_with_prefix_include_filters(client, live_server): +def test_check_with_prefix_include_filters(client, live_server, measure_memory_usage): res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data @@ -378,7 +378,7 @@ def test_check_with_prefix_include_filters(client, live_server): client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_various_rules(client, live_server): +def test_various_rules(client, live_server, measure_memory_usage): # Just check these don't error # live_server_setup(live_server) with open("test-datastore/endpoint-content.txt", "w") as f: @@ -426,7 +426,7 @@ def test_various_rules(client, live_server): assert b'Deleted' in res.data -def test_xpath_20(client, live_server): +def test_xpath_20(client, live_server, measure_memory_usage): test_url = url_for('test_endpoint', _external=True) res = client.post( url_for("import_page"), @@ -463,7 +463,7 @@ def test_xpath_20(client, live_server): client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_xpath_20_function_count(client, live_server): +def test_xpath_20_function_count(client, live_server, measure_memory_usage): set_original_response() # Add our URL to the import page @@ -499,7 +499,7 @@ def test_xpath_20_function_count(client, live_server): client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_xpath_20_function_count2(client, live_server): +def test_xpath_20_function_count2(client, live_server, measure_memory_usage): set_original_response() # Add our URL to the import page @@ -535,7 +535,7 @@ def test_xpath_20_function_count2(client, live_server): client.get(url_for("form_delete", uuid="all"), follow_redirects=True) -def test_xpath_20_function_string_join_matches(client, live_server): +def test_xpath_20_function_string_join_matches(client, live_server, measure_memory_usage): set_original_response() # Add our URL to the import page diff --git a/changedetectionio/tests/visualselector/test_fetch_data.py b/changedetectionio/tests/visualselector/test_fetch_data.py index 15677f31..e0710c43 100644 --- a/changedetectionio/tests/visualselector/test_fetch_data.py +++ b/changedetectionio/tests/visualselector/test_fetch_data.py @@ -4,12 +4,12 @@ import os from flask import url_for from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client -def test_setup(client, live_server): +def test_setup(client, live_server, measure_memory_usage): live_server_setup(live_server) # Add a site in paused mode, add an invalid filter, we should still have visual selector data ready -def test_visual_selector_content_ready(client, live_server): +def test_visual_selector_content_ready(client, live_server, measure_memory_usage): import os import json @@ -79,7 +79,7 @@ def test_visual_selector_content_ready(client, live_server): follow_redirects=True ) -def test_basic_browserstep(client, live_server): +def test_basic_browserstep(client, live_server, measure_memory_usage): #live_server_setup(live_server) assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test"