Skip to content

Commit 5ed3ed4

Browse files
committed
fix tests
1 parent d1ece65 commit 5ed3ed4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pymongo/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
# Default value for serverMonitoringMode
140140
SERVER_MONITORING_MODE = "auto" # poll/stream/auto
141141

142+
# Options that must raise an error instead of warning if they invalidate.
143+
_OPTION_MUST_RAISE = ["CANONICALIZE_HOST_NAME"]
144+
142145

143146
def partition_node(node: str) -> tuple[str, int]:
144147
"""Split a host:port string into (host, int(port)) pair."""
@@ -870,7 +873,7 @@ def get_setter_key(x: str) -> str:
870873
validator = _get_validator(opt, URI_OPTIONS_VALIDATOR_MAP, normed_key=normed_key)
871874
validated = validator(opt, value)
872875
except (ValueError, TypeError, ConfigurationError) as exc:
873-
if warn:
876+
if warn and opt not in _OPTION_MUST_RAISE:
874877
warnings.warn(str(exc), stacklevel=2)
875878
else:
876879
raise

0 commit comments

Comments
 (0)