From 1945ce7c73d2f6ecbf92fac0b90974a23aac4968 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Mon, 30 Dec 2024 21:28:53 +0100 Subject: [PATCH] Extend defaults testing to other _date parameters --- tests/auxil/bot_method_checks.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/auxil/bot_method_checks.py b/tests/auxil/bot_method_checks.py index 317042d25..e3d4d2a53 100644 --- a/tests/auxil/bot_method_checks.py +++ b/tests/auxil/bot_method_checks.py @@ -345,7 +345,7 @@ def build_kwargs( # Some special casing for methods that have "exactly one of the optionals" type args elif name in ["location", "contact", "venue", "inline_message_id"]: kws[name] = True - elif name == "until_date": + elif name.endswith("_date"): if manually_passed_value not in [None, DEFAULT_NONE]: # Europe/Berlin kws[name] = dtm.datetime(2000, 1, 1, 0, tzinfo=zoneinfo.ZoneInfo("Europe/Berlin")) @@ -531,14 +531,19 @@ async def make_assertion( ) # Check datetime conversion - until_date = data.pop("until_date", None) - if until_date: - if manual_value_expected and until_date != 946681200: - pytest.fail("Non-naive until_date should have been interpreted as Europe/Berlin.") - if not any((manually_passed_value, expected_defaults_value)) and until_date != 946684800: - pytest.fail("Naive until_date should have been interpreted as UTC") - if default_value_expected and until_date != 946702800: - pytest.fail("Naive until_date should have been interpreted as America/New_York") + date_keys = [key for key in data if key.endswith("_date")] + for key in date_keys: + date_param = data.pop(key) + if date_param: + if manual_value_expected and date_param != 946681200: + pytest.fail(f"Non-naive `{key}` should have been interpreted as Europe/Berlin.") + if ( + not any((manually_passed_value, expected_defaults_value)) + and date_param != 946684800 + ): + pytest.fail(f"Naive `{key}` should have been interpreted as UTC") + if default_value_expected and date_param != 946702800: + pytest.fail(f"Naive `{key}` should have been interpreted as America/New_York") if method_name in ["get_file", "get_small_file", "get_big_file"]: # This is here mainly for PassportFile.get_file, which calls .set_credentials on the