Skip to content

Commit 275b716

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents 104ec91 + fe0faf7 commit 275b716

File tree

7 files changed

+27
-55
lines changed

7 files changed

+27
-55
lines changed

.evergreen/run-mod-wsgi-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fi
1919
PYTHON_VERSION=$(${PYTHON_BINARY} -c "import sys; sys.stdout.write('.'.join(str(val) for val in sys.version_info[:2]))")
2020

2121
# Ensure the C extensions are installed.
22-
${PYTHON_BINARY} setup.py build_ext -i
22+
${PYTHON_BINARY} -m pip install -e .
2323

2424
export MOD_WSGI_SO=/opt/python/mod_wsgi/python_version/$PYTHON_VERSION/mod_wsgi_version/$MOD_WSGI_VERSION/mod_wsgi.so
2525
export PYTHONHOME=/opt/python/$PYTHON_VERSION

test/test_client.py

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import sys
3131
import threading
3232
import time
33-
import warnings
3433
from typing import Iterable, Type, no_type_check
3534
from unittest import mock
3635
from unittest.mock import patch
@@ -617,7 +616,7 @@ def test_max_idle_time_reaper_default(self):
617616
with client_knobs(kill_cursor_frequency=0.1):
618617
# Assert reaper doesn't remove connections when maxIdleTimeMS not set
619618
client = rs_or_single_client()
620-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
619+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
621620
with server._pool.checkout() as conn:
622621
pass
623622
self.assertEqual(1, len(server._pool.conns))
@@ -628,7 +627,7 @@ def test_max_idle_time_reaper_removes_stale_minPoolSize(self):
628627
with client_knobs(kill_cursor_frequency=0.1):
629628
# Assert reaper removes idle socket and replaces it with a new one
630629
client = rs_or_single_client(maxIdleTimeMS=500, minPoolSize=1)
631-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
630+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
632631
with server._pool.checkout() as conn:
633632
pass
634633
# When the reaper runs at the same time as the get_socket, two
@@ -642,7 +641,7 @@ def test_max_idle_time_reaper_does_not_exceed_maxPoolSize(self):
642641
with client_knobs(kill_cursor_frequency=0.1):
643642
# Assert reaper respects maxPoolSize when adding new connections.
644643
client = rs_or_single_client(maxIdleTimeMS=500, minPoolSize=1, maxPoolSize=1)
645-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
644+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
646645
with server._pool.checkout() as conn:
647646
pass
648647
# When the reaper runs at the same time as the get_socket,
@@ -656,7 +655,7 @@ def test_max_idle_time_reaper_removes_stale(self):
656655
with client_knobs(kill_cursor_frequency=0.1):
657656
# Assert reaper has removed idle socket and NOT replaced it
658657
client = rs_or_single_client(maxIdleTimeMS=500)
659-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
658+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
660659
with server._pool.checkout() as conn_one:
661660
pass
662661
# Assert that the pool does not close connections prematurely.
@@ -673,12 +672,12 @@ def test_max_idle_time_reaper_removes_stale(self):
673672
def test_min_pool_size(self):
674673
with client_knobs(kill_cursor_frequency=0.1):
675674
client = rs_or_single_client()
676-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
675+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
677676
self.assertEqual(0, len(server._pool.conns))
678677

679678
# Assert that pool started up at minPoolSize
680679
client = rs_or_single_client(minPoolSize=10)
681-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
680+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
682681
wait_until(
683682
lambda: len(server._pool.conns) == 10,
684683
"pool initialized with 10 connections",
@@ -697,7 +696,7 @@ def test_max_idle_time_checkout(self):
697696
# Use high frequency to test _get_socket_no_auth.
698697
with client_knobs(kill_cursor_frequency=99999999):
699698
client = rs_or_single_client(maxIdleTimeMS=500)
700-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
699+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
701700
with server._pool.checkout() as conn:
702701
pass
703702
self.assertEqual(1, len(server._pool.conns))
@@ -711,7 +710,7 @@ def test_max_idle_time_checkout(self):
711710

712711
# Test that connections are reused if maxIdleTimeMS is not set.
713712
client = rs_or_single_client()
714-
server = client._get_topology()._select_server(readable_server_selector, _Op.TEST)
713+
server = client._get_topology().select_server(readable_server_selector, _Op.TEST)
715714
with server._pool.checkout() as conn:
716715
pass
717716
self.assertEqual(1, len(server._pool.conns))
@@ -1180,9 +1179,7 @@ def test_server_selection_timeout(self):
11801179
client = MongoClient(serverSelectionTimeoutMS=100, connect=False)
11811180
self.assertAlmostEqual(0.1, client.options.server_selection_timeout)
11821181

1183-
with warnings.catch_warnings():
1184-
warnings.simplefilter("ignore", UserWarning)
1185-
client = MongoClient(serverSelectionTimeoutMS=0, connect=False)
1182+
client = MongoClient(serverSelectionTimeoutMS=0, connect=False)
11861183

11871184
self.assertAlmostEqual(0, client.options.server_selection_timeout)
11881185

@@ -1195,20 +1192,14 @@ def test_server_selection_timeout(self):
11951192
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=100", connect=False)
11961193
self.assertAlmostEqual(0.1, client.options.server_selection_timeout)
11971194

1198-
with warnings.catch_warnings():
1199-
warnings.simplefilter("ignore", UserWarning)
1200-
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=0", connect=False)
1195+
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=0", connect=False)
12011196
self.assertAlmostEqual(0, client.options.server_selection_timeout)
12021197

12031198
# Test invalid timeout in URI ignored and set to default.
1204-
with warnings.catch_warnings():
1205-
warnings.simplefilter("ignore", UserWarning)
1206-
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=-1", connect=False)
1199+
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=-1", connect=False)
12071200
self.assertAlmostEqual(30, client.options.server_selection_timeout)
12081201

1209-
with warnings.catch_warnings():
1210-
warnings.simplefilter("ignore", UserWarning)
1211-
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=", connect=False)
1202+
client = MongoClient("mongodb://localhost/?serverSelectionTimeoutMS=", connect=False)
12121203
self.assertAlmostEqual(30, client.options.server_selection_timeout)
12131204

12141205
def test_waitQueueTimeoutMS(self):
@@ -1550,33 +1541,25 @@ def compression_settings(client):
15501541
self.assertEqual(opts.compressors, [])
15511542
self.assertEqual(opts.zlib_compression_level, -1)
15521543
uri = "mongodb://localhost:27017/?compressors=foobar"
1553-
with warnings.catch_warnings():
1554-
warnings.simplefilter("ignore", UserWarning)
1555-
client = MongoClient(uri, connect=False)
1544+
client = MongoClient(uri, connect=False)
15561545
opts = compression_settings(client)
15571546
self.assertEqual(opts.compressors, [])
15581547
self.assertEqual(opts.zlib_compression_level, -1)
15591548
uri = "mongodb://localhost:27017/?compressors=foobar,zlib"
1560-
with warnings.catch_warnings():
1561-
warnings.simplefilter("ignore", UserWarning)
1562-
client = MongoClient(uri, connect=False)
1549+
client = MongoClient(uri, connect=False)
15631550
opts = compression_settings(client)
15641551
self.assertEqual(opts.compressors, ["zlib"])
15651552
self.assertEqual(opts.zlib_compression_level, -1)
15661553

15671554
# According to the connection string spec, unsupported values
15681555
# just raise a warning and are ignored.
15691556
uri = "mongodb://localhost:27017/?compressors=zlib&zlibCompressionLevel=10"
1570-
with warnings.catch_warnings():
1571-
warnings.simplefilter("ignore", UserWarning)
1572-
client = MongoClient(uri, connect=False)
1557+
client = MongoClient(uri, connect=False)
15731558
opts = compression_settings(client)
15741559
self.assertEqual(opts.compressors, ["zlib"])
15751560
self.assertEqual(opts.zlib_compression_level, -1)
15761561
uri = "mongodb://localhost:27017/?compressors=zlib&zlibCompressionLevel=-2"
1577-
with warnings.catch_warnings():
1578-
warnings.simplefilter("ignore", UserWarning)
1579-
client = MongoClient(uri, connect=False)
1562+
client = MongoClient(uri, connect=False)
15801563
opts = compression_settings(client)
15811564
self.assertEqual(opts.compressors, ["zlib"])
15821565
self.assertEqual(opts.zlib_compression_level, -1)
@@ -1598,9 +1581,7 @@ def compression_settings(client):
15981581

15991582
if not _have_zstd():
16001583
uri = "mongodb://localhost:27017/?compressors=zstd"
1601-
with warnings.catch_warnings():
1602-
warnings.simplefilter("ignore", UserWarning)
1603-
client = MongoClient(uri, connect=False)
1584+
client = MongoClient(uri, connect=False)
16041585
opts = compression_settings(client)
16051586
self.assertEqual(opts.compressors, [])
16061587
else:

test/test_fork.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def target():
6565
with self.fork(target):
6666
pass
6767

68-
@unittest.skip("testing")
6968
def test_topology_reset(self):
7069
# Tests that topologies are different from each other.
7170
# Cannot use ID because virtual memory addresses may be the same.

test/test_gridfs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,13 @@ def test_gridfs_find(self):
443443
cursor.close()
444444
self.assertRaises(TypeError, self.fs.find, {}, {"_id": True})
445445

446-
# def test_delete_not_initialized(self):
447-
# # Creating a cursor with invalid arguments will not run __init__
448-
# # but will still call __del__.
449-
# cursor = GridOutCursor.__new__(GridOutCursor) # Skip calling __init__
450-
# with self.assertRaises(TypeError):
451-
# cursor.__init__(self.db.fs.files, {}, {"_id": True}) # type: ignore
452-
# cursor.__del__() # no error
446+
def test_delete_not_initialized(self):
447+
# Creating a cursor with invalid arguments will not run __init__
448+
# but will still call __del__.
449+
cursor = GridOutCursor.__new__(GridOutCursor) # Skip calling __init__
450+
with self.assertRaises(TypeError):
451+
cursor.__init__(self.db.fs.files, {}, {"_id": True}) # type: ignore
452+
cursor.__del__() # no error
453453

454454
def test_gridfs_find_one(self):
455455
self.assertEqual(None, self.fs.find_one())

test/test_mongos_load_balancing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def test_lazy_connect(self):
8989
# While connected() ensures we can trigger connection from the main
9090
# thread and wait for the monitors, this test triggers connection from
9191
# several threads at once to check for data races.
92-
raise unittest.SkipTest("skip for now")
9392
nthreads = 10
9493
client = self.mock_client()
9594
self.assertEqual(0, len(client.nodes))

test/test_read_preferences.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@ def _conn_from_server(self, read_preference, server, session):
300300
self.record_a_read(conn.address)
301301
yield conn, read_preference
302302

303-
async def _socket_for_reads_async(self, read_preference, session):
304-
context = await super()._socket_for_reads_async(read_preference, session)
305-
async with context as (sock_info, read_preference):
306-
self.record_a_read(sock_info.address)
307-
return await super()._socket_for_reads_async(read_preference, session)
308-
309303
def record_a_read(self, address):
310304
server = self._get_topology().select_server_by_address(address, _Op.TEST, 0)
311305
self.has_read_from.add(server)

test/test_session.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ def test_implicit_sessions_checkout(self):
185185
# "To confirm that implicit sessions only allocate their server session after a
186186
# successful connection checkout" test from Driver Sessions Spec.
187187
succeeded = False
188-
raise unittest.SkipTest("temporary skip")
189188
lsid_set = set()
190189
failures = 0
191190
for _ in range(5):
@@ -297,8 +296,8 @@ def test_client(self):
297296
client = self.client
298297
ops: list = [
299298
(client.server_info, [], {}),
300-
# (client.list_database_names, [], {}),
301-
# (client.drop_database, ["pymongo_test"], {}),
299+
(client.list_database_names, [], {}),
300+
(client.drop_database, ["pymongo_test"], {}),
302301
]
303302

304303
self._test_ops(client, *ops)

0 commit comments

Comments
 (0)