From 2fced014c67e2e34852df9091b782492310dd61a Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 16 Aug 2023 11:18:35 -0500 Subject: [PATCH 1/8] PYTHON-3917 [Build Failure] test_connection_string_test_valid-auth_At-signs_in_options_aren_t_part_of_the_userinfo --- test/test_uri_spec.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index 5b68c80401..3ad9c09196 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -73,8 +73,10 @@ def setUp(self): clear_warning_registry() -def get_error_message_template(expected, artefact): - return "{} {} for test '{}'".format("Expected" if expected else "Unexpected", artefact, "%s") +def get_error_message_template(expected, artifact, actual): + return "{} {} for test '{}', got: {}".format( + "Expected" if expected else "Unexpected", artifact, "%s", actual + ) def run_scenario_in_dir(target_workdir): From 4f9489b3ffc0cde3ca230daf1251199d53a5697b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 16 Aug 2023 12:09:53 -0500 Subject: [PATCH 2/8] debug --- test/test_uri_spec.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index 3ad9c09196..213715db2a 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -73,9 +73,9 @@ def setUp(self): clear_warning_registry() -def get_error_message_template(expected, artifact, actual): +def get_error_message_template(expected, artifact): return "{} {} for test '{}', got: {}".format( - "Expected" if expected else "Unexpected", artifact, "%s", actual + "Expected" if expected else "Unexpected", artifact, "%s" ) @@ -101,6 +101,7 @@ def run_scenario(self): self.skipTest("This test needs dnspython package.") valid = True warning = False + expected_warning = test.get("warning", False) with warnings.catch_warnings(record=True) as ctx: warnings.simplefilter("always") @@ -110,6 +111,8 @@ def run_scenario(self): valid = False else: warning = len(ctx) > 0 + if warning and not expected_warning: + print("**DEBUG**", ctx) expected_valid = test.get("valid", True) self.assertEqual( @@ -119,7 +122,7 @@ def run_scenario(self): ) if expected_valid: - expected_warning = test.get("warning", False) + self.assertEqual( warning, expected_warning, From a595c794dc8938ff0ad50caae58548bb37e12225 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 16 Aug 2023 12:25:42 -0500 Subject: [PATCH 3/8] formatting --- test/test_uri_spec.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index 213715db2a..d9d33ba429 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -74,9 +74,7 @@ def setUp(self): def get_error_message_template(expected, artifact): - return "{} {} for test '{}', got: {}".format( - "Expected" if expected else "Unexpected", artifact, "%s" - ) + return "{} {} for test '{}'".format("Expected" if expected else "Unexpected", artifact, "%s") def run_scenario_in_dir(target_workdir): From b6fdc9dd5d65351bd08361954d43a3d220007fb9 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 16 Aug 2023 12:42:15 -0500 Subject: [PATCH 4/8] debug --- test/test_uri_spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index d9d33ba429..3bfdb441a5 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -109,7 +109,7 @@ def run_scenario(self): valid = False else: warning = len(ctx) > 0 - if warning and not expected_warning: + if warning != expected_warning: print("**DEBUG**", ctx) expected_valid = test.get("valid", True) From e22233e388c3a28285f5310f93584a12a81a46f5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 16 Aug 2023 21:54:40 -0500 Subject: [PATCH 5/8] update debug message --- test/test_uri_spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index 3bfdb441a5..a221b71221 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -110,7 +110,7 @@ def run_scenario(self): else: warning = len(ctx) > 0 if warning != expected_warning: - print("**DEBUG**", ctx) + print("**DEBUG**", [str(i) for i in ctx]) expected_valid = test.get("valid", True) self.assertEqual( From 1446ebc5356efeb081557b8928b35cccf5108449 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 17 Aug 2023 07:26:36 -0500 Subject: [PATCH 6/8] convert warnings to errors --- test/test_uri_spec.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index a221b71221..c09051a092 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -100,6 +100,7 @@ def run_scenario(self): valid = True warning = False expected_warning = test.get("warning", False) + expected_valid = test.get("valid", True) with warnings.catch_warnings(record=True) as ctx: warnings.simplefilter("always") @@ -109,10 +110,9 @@ def run_scenario(self): valid = False else: warning = len(ctx) > 0 - if warning != expected_warning: - print("**DEBUG**", [str(i) for i in ctx]) + if expected_valid and warning and not expected_warning: + raise ValueError("Got unexpected warning(s): ", [str(i) for i in ctx]) - expected_valid = test.get("valid", True) self.assertEqual( valid, expected_valid, @@ -120,7 +120,6 @@ def run_scenario(self): ) if expected_valid: - self.assertEqual( warning, expected_warning, From 1ea0f7afc524cc3ef806f3e8945a427e3dd6e296 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 17 Aug 2023 08:08:28 -0500 Subject: [PATCH 7/8] ignore resource warnings --- test/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index 846d4a279e..fe472560b5 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1151,7 +1151,7 @@ def tearDown(self): def setup(): client_context.init() warnings.resetwarnings() - warnings.simplefilter("always") + warnings.simplefilter("ignore", ResourceWarning) global_knobs.enable() From 4e93bf73e35b2d6ea1c71480a2dc484f7faaff4f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 17 Aug 2023 08:38:20 -0500 Subject: [PATCH 8/8] ignore resource warnings --- test/__init__.py | 2 +- test/test_uri_spec.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index fe472560b5..846d4a279e 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1151,7 +1151,7 @@ def tearDown(self): def setup(): client_context.init() warnings.resetwarnings() - warnings.simplefilter("ignore", ResourceWarning) + warnings.simplefilter("always") global_knobs.enable() diff --git a/test/test_uri_spec.py b/test/test_uri_spec.py index c09051a092..5896b5e124 100644 --- a/test/test_uri_spec.py +++ b/test/test_uri_spec.py @@ -103,7 +103,7 @@ def run_scenario(self): expected_valid = test.get("valid", True) with warnings.catch_warnings(record=True) as ctx: - warnings.simplefilter("always") + warnings.simplefilter("ignore", category=ResourceWarning) try: options = parse_uri(test["uri"], warn=True) except Exception: