Skip to content

Commit 821b562

Browse files
authored
PYTHON-3198 Fix NameError: name sys is not defined (#920)
1 parent 331600d commit 821b562

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pymongo/uri_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
"""Tools to parse and validate a MongoDB URI."""
1717
import re
18+
import sys
1819
import warnings
1920
from typing import Any, Dict, List, Mapping, MutableMapping, Optional, Tuple, Union
2021
from urllib.parse import unquote_plus
@@ -615,7 +616,6 @@ def _parse_kms_tls_options(kms_tls_options):
615616

616617
if __name__ == "__main__":
617618
import pprint
618-
import sys
619619

620620
try:
621621
pprint.pprint(parse_uri(sys.argv[1]))

test/test_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,11 @@ def test_srv_max_hosts_kwarg(self):
16891689
)
16901690
self.assertEqual(len(client.topology_description.server_descriptions()), 2)
16911691

1692+
@unittest.skipIf(_HAVE_DNSPYTHON, "dnspython must not be installed")
1693+
def test_srv_no_dnspython_error(self):
1694+
with self.assertRaisesRegex(ConfigurationError, 'The "dnspython" module must be'):
1695+
MongoClient("mongodb+srv://test1.test.build.10gen.cc/")
1696+
16921697
@unittest.skipIf(
16931698
client_context.load_balancer or client_context.serverless,
16941699
"loadBalanced clients do not run SDAM",

0 commit comments

Comments
 (0)