Skip to content

Commit 56affb4

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents a0994a5 + bfaab82 commit 56affb4

34 files changed

+292
-1391
lines changed

.evergreen/remove-unimplemented-tests.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,17 @@ rm $PYMONGO/test/crud/unified/updateMany-rawdata.json
4141
rm $PYMONGO/test/crud/unified/updateOne-rawdata.json
4242
rm $PYMONGO/test/index_management/index-rawdata.json
4343

44-
echo "Done removing unimplemented tests\n"
44+
# PyMongo does not support modifyCollection
45+
rm $PYMONGO/test/collection_management/modifyCollection-*.json
46+
47+
# PYTHON-5248 - Remove support for MongoDB 4.0
48+
rm $PYMONGO/test/**/pre-42-*.json
49+
50+
# PYTHON-3359 - Remove Database and Collection level timeout override
51+
rm $PYMONGO/test/csot/override-collection-timeoutMS.json
52+
rm $PYMONGO/test/csot/override-database-timeoutMS.json
53+
54+
# PYTHON-2943 - Socks5 Proxy Support
55+
rm $PYMONGO/test/uri_options/proxy-options.json
56+
57+
echo "Done removing unimplemented tests"

.evergreen/scripts/resync-all-specs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None:
3333
def apply_patches():
3434
print("Beginning to apply patches") # noqa: T201
3535
subprocess.run(["bash", "./.evergreen/remove-unimplemented-tests.sh"], check=True) # noqa: S603, S607
36-
subprocess.run(["git apply -R --allow-empty ./.evergreen/spec-patch/*"], shell=True, check=True) # noqa: S602, S607
36+
subprocess.run(
37+
["git apply -R --allow-empty --whitespace=fix ./.evergreen/spec-patch/*"], # noqa: S607
38+
shell=True, # noqa: S602
39+
check=True,
40+
)
3741

3842

3943
def check_new_spec_directories(directory: pathlib.Path) -> list[str]:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff --git a/test/load_balancer/cursors.json b/test/load_balancer/cursors.json
2+
index 43e4fbb4f..4e2a55fd4 100644
3+
--- a/test/load_balancer/cursors.json
4+
+++ b/test/load_balancer/cursors.json
5+
@@ -376,7 +376,7 @@
6+
]
7+
},
8+
{
9+
+ "description": "pinned connections are not returned after an network error during getMore",
10+
- "description": "pinned connections are returned after an network error during getMore",
11+
"operations": [
12+
{
13+
"name": "failPoint",
14+
@@ -440,7 +440,7 @@
15+
"object": "testRunner",
16+
"arguments": {
17+
"client": "client0",
18+
+ "connections": 1
19+
- "connections": 0
20+
}
21+
},
22+
{
23+
@@ -659,7 +659,7 @@
24+
]
25+
},
26+
{
27+
+ "description": "pinned connections are not returned to the pool after a non-network error on getMore",
28+
- "description": "pinned connections are returned to the pool after a non-network error on getMore",
29+
"operations": [
30+
{
31+
"name": "failPoint",
32+
@@ -715,7 +715,7 @@
33+
"object": "testRunner",
34+
"arguments": {
35+
"client": "client0",
36+
+ "connections": 1
37+
- "connections": 0
38+
}
39+
},
40+
{
41+
diff --git a/test/load_balancer/sdam-error-handling.json b/test/load_balancer/sdam-error-handling.json
42+
index 63aabc04d..462fa0aac 100644
43+
--- a/test/load_balancer/sdam-error-handling.json
44+
+++ b/test/load_balancer/sdam-error-handling.json
45+
@@ -366,6 +366,9 @@
46+
{
47+
"connectionCreatedEvent": {}
48+
},
49+
+ {
50+
+ "poolClearedEvent": {}
51+
+ },
52+
{
53+
"connectionClosedEvent": {
54+
"reason": "error"
55+
@@ -378,9 +375,6 @@
56+
"connectionCheckOutFailedEvent": {
57+
"reason": "connectionError"
58+
}
59+
- },
60+
- {
61+
- "poolClearedEvent": {}
62+
}
63+
]
64+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/test/discovery_and_monitoring/unified/serverMonitoringMode.json b/test/discovery_and_monitoring/unified/serverMonitoringMode.json
2+
index 4b492f7d8..e44fad1bc 100644
3+
--- a/test/discovery_and_monitoring/unified/serverMonitoringMode.json
4+
+++ b/test/discovery_and_monitoring/unified/serverMonitoringMode.json
5+
@@ -5,8 +5,7 @@
6+
{
7+
"topologies": [
8+
"single",
9+
+ "sharded"
10+
- "sharded",
11+
- "sharded-replicaset"
12+
],
13+
"serverless": "forbid"
14+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
diff --git a/test/server_selection_logging/replica-set.json b/test/server_selection_logging/replica-set.json
2+
index 830b1ea51..5eba784bf 100644
3+
--- a/test/server_selection_logging/replica-set.json
4+
+++ b/test/server_selection_logging/replica-set.json
5+
@@ -184,7 +184,7 @@
6+
}
7+
},
8+
{
9+
- "level": "debug",
10+
+ "level": "info",
11+
"component": "serverSelection",
12+
"data": {
13+
"message": "Waiting for suitable server to become available",
14+
diff --git a/test/server_selection_logging/standalone.json b/test/server_selection_logging/standalone.json
15+
index 830b1ea51..5eba784bf 100644
16+
--- a/test/server_selection_logging/standalone.json
17+
+++ b/test/server_selection_logging/standalone.json
18+
@@ -191,7 +191,7 @@
19+
}
20+
},
21+
{
22+
- "level": "debug",
23+
+ "level": "info",
24+
"component": "serverSelection",
25+
"data": {
26+
"message": "Waiting for suitable server to become available",
27+
diff --git a/test/server_selection_logging/sharded.json b/test/server_selection_logging/sharded.json
28+
index 830b1ea51..5eba784bf 100644
29+
--- a/test/server_selection_logging/sharded.json
30+
+++ b/test/server_selection_logging/sharded.json
31+
@@ -193,7 +193,7 @@
32+
}
33+
},
34+
{
35+
- "level": "debug",
36+
+ "level": "info",
37+
"component": "serverSelection",
38+
"data": {
39+
"message": "Waiting for suitable server to become available",
40+
diff --git a/test/server_selection_logging/sharded.json b/test/server_selection_logging/operation-id.json
41+
index 830b1ea51..5eba784bf 100644
42+
--- a/test/server_selection_logging/operation-id.json
43+
+++ b/test/server_selection_logging/operation-id.json
44+
@@ -197,7 +197,7 @@
45+
}
46+
},
47+
{
48+
- "level": "debug",
49+
+ "level": "info",
50+
"component": "serverSelection",
51+
"data": {
52+
"message": "Waiting for suitable server to become available",
53+
@@ -383,7 +383,7 @@
54+
}
55+
},
56+
{
57+
- "level": "debug",
58+
+ "level": "info",
59+
"component": "serverSelection",
60+
"data": {
61+
"message": "Waiting for suitable server to become available",

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3
49+
uses: github/codeql-action/init@4e828ff8d448a8a6e532957b1811f387a63867e8 # v3
5050
with:
5151
languages: ${{ matrix.language }}
5252
build-mode: ${{ matrix.build-mode }}
@@ -63,6 +63,6 @@ jobs:
6363
pip install -e .
6464
6565
- name: Perform CodeQL Analysis
66-
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3
66+
uses: github/codeql-action/analyze@4e828ff8d448a8a6e532957b1811f387a63867e8 # v3
6767
with:
6868
category: "/language:${{matrix.language}}"

.github/workflows/test-python.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install just
2626
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
2727
- name: Install uv
28-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
28+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
2929
with:
3030
enable-cache: true
3131
python-version: "3.9"
@@ -65,7 +65,7 @@ jobs:
6565
- name: Install just
6666
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
6767
- name: Install uv
68-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
68+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
6969
with:
7070
enable-cache: true
7171
python-version: ${{ matrix.python-version }}
@@ -88,7 +88,7 @@ jobs:
8888
- name: Install just
8989
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
9090
- name: Install uv
91-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
91+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
9292
with:
9393
enable-cache: true
9494
python-version: "3.9"
@@ -111,7 +111,7 @@ jobs:
111111
with:
112112
persist-credentials: false
113113
- name: Install uv
114-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
114+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
115115
with:
116116
enable-cache: true
117117
python-version: "3.9"
@@ -130,7 +130,7 @@ jobs:
130130
with:
131131
persist-credentials: false
132132
- name: Install uv
133-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
133+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
134134
with:
135135
enable-cache: true
136136
python-version: "3.9"
@@ -152,7 +152,7 @@ jobs:
152152
with:
153153
persist-credentials: false
154154
- name: Install uv
155-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
155+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
156156
with:
157157
enable-cache: true
158158
python-version: "${{matrix.python}}"
@@ -231,7 +231,7 @@ jobs:
231231
with:
232232
persist-credentials: false
233233
- name: Install uv
234-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
234+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
235235
with:
236236
python-version: '3.9'
237237
- name: Start MongoDB
@@ -257,7 +257,7 @@ jobs:
257257
with:
258258
persist-credentials: false
259259
- name: Install uv
260-
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v5
260+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5
261261
with:
262262
python-version: '3.9'
263263
- name: Start MongoDB

.github/workflows/zizmor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
with:
1919
persist-credentials: false
2020
- name: Run zizmor 🌈
21-
uses: zizmorcore/zizmor-action@1c7106082dbc1753372e3924b7da1b9417011a21
21+
uses: zizmorcore/zizmor-action@87e33752ad17c7c7fc16fe27c858900c59b18d77

test/asynchronous/test_database.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async def test_list_collection_names(self):
189189
filter={"name": {"$regex": r"^(?!system\.)"}}
190190
)
191191
for coll in no_system_collections:
192-
self.assertTrue(not coll.startswith("system."))
192+
self.assertFalse(coll.startswith("system."))
193193
self.assertIn("systemcoll.test", no_system_collections)
194194

195195
# Force more than one batch.
@@ -265,19 +265,13 @@ async def test_list_collections(self):
265265
try:
266266
# Found duplicate.
267267
coll_cnt[coll] += 1
268-
self.assertTrue(False)
268+
self.fail("Found duplicate")
269269
except KeyError:
270270
coll_cnt[coll] = 1
271271
coll_cnt: dict = {}
272272

273-
# Checking if is there any collection which don't exists.
274-
if (
275-
len(set(colls) - {"test", "test.mike"}) == 0
276-
or len(set(colls) - {"test", "test.mike", "system.indexes"}) == 0
277-
):
278-
self.assertTrue(True)
279-
else:
280-
self.assertTrue(False)
273+
# Check if there are any collections which don't exist.
274+
self.assertLessEqual(set(colls), {"test", "test.mike", "system.indexes"})
281275

282276
colls = await (await db.list_collections(filter={"name": {"$regex": "^test$"}})).to_list()
283277
self.assertEqual(1, len(colls))
@@ -307,16 +301,13 @@ async def test_list_collections(self):
307301
try:
308302
# Found duplicate.
309303
coll_cnt[coll] += 1
310-
self.assertTrue(False)
304+
self.fail("Found duplicate")
311305
except KeyError:
312306
coll_cnt[coll] = 1
313307
coll_cnt = {}
314308

315-
# Checking if is there any collection which don't exists.
316-
if len(set(colls) - {"test"}) == 0 or len(set(colls) - {"test", "system.indexes"}) == 0:
317-
self.assertTrue(True)
318-
else:
319-
self.assertTrue(False)
309+
# Check if there are any collections which don't exist.
310+
self.assertLessEqual(set(colls), {"test", "system.indexes"})
320311

321312
await self.client.drop_database("pymongo_test")
322313

test/asynchronous/test_gridfs_bucket.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,16 @@ async def test_upload_ensures_index(self):
164164
await files.drop()
165165
await self.fs.upload_from_stream("filename", b"junk")
166166

167-
self.assertTrue(
168-
any(
169-
info.get("key") == [("files_id", 1), ("n", 1)]
170-
for info in (await chunks.index_information()).values()
171-
)
167+
self.assertIn(
168+
[("files_id", 1), ("n", 1)],
169+
[info.get("key") for info in (await chunks.index_information()).values()],
170+
"Missing required index on chunks collection: {files_id: 1, n: 1}",
172171
)
173-
self.assertTrue(
174-
any(
175-
info.get("key") == [("filename", 1), ("uploadDate", 1)]
176-
for info in (await files.index_information()).values()
177-
)
172+
173+
self.assertIn(
174+
[("filename", 1), ("uploadDate", 1)],
175+
[info.get("key") for info in (await files.index_information()).values()],
176+
"Missing required index on files collection: {filename: 1, uploadDate: 1}",
178177
)
179178

180179
async def test_ensure_index_shell_compat(self):
@@ -192,11 +191,10 @@ async def test_ensure_index_shell_compat(self):
192191
# No error.
193192
await self.fs.upload_from_stream("filename", b"data")
194193

195-
self.assertTrue(
196-
any(
197-
info.get("key") == [("filename", 1), ("uploadDate", 1)]
198-
for info in (await files.index_information()).values()
199-
)
194+
self.assertIn(
195+
[("filename", 1), ("uploadDate", 1)],
196+
[info.get("key") for info in (await files.index_information()).values()],
197+
"Missing required index on files collection: {filename: 1, uploadDate: 1}",
200198
)
201199
await files.drop()
202200

0 commit comments

Comments
 (0)