Skip to content

Commit 6b141d1

Browse files
authored
PYTHON-5096 - Convert test.test_retryable_reads_unified to async (#2112)
1 parent acc437a commit 6b141d1

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2022-present MongoDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Test the Retryable Reads unified spec tests."""
16+
from __future__ import annotations
17+
18+
import os
19+
import sys
20+
from pathlib import Path
21+
22+
sys.path[0:0] = [""]
23+
24+
from test import unittest
25+
from test.asynchronous.unified_format import generate_test_classes
26+
27+
_IS_SYNC = False
28+
29+
# Location of JSON test specifications.
30+
if _IS_SYNC:
31+
TEST_PATH = os.path.join(Path(__file__).resolve().parent, "retryable_reads/unified")
32+
else:
33+
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "retryable_reads/unified")
34+
35+
# Generate unified tests.
36+
# PyMongo does not support MapReduce, ListDatabaseObjects or ListCollectionObjects.
37+
globals().update(
38+
generate_test_classes(
39+
TEST_PATH,
40+
module=__name__,
41+
expected_failures=["ListDatabaseObjects .*", "ListCollectionObjects .*", "MapReduce .*"],
42+
)
43+
)
44+
45+
if __name__ == "__main__":
46+
unittest.main()

test/test_retryable_reads_unified.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Test the Retryable Reads unified spec tests."""
1616
from __future__ import annotations
1717

18+
import os
1819
import sys
1920
from pathlib import Path
2021

@@ -23,8 +24,13 @@
2324
from test import unittest
2425
from test.unified_format import generate_test_classes
2526

27+
_IS_SYNC = True
28+
2629
# Location of JSON test specifications.
27-
TEST_PATH = Path(__file__).parent / "retryable_reads/unified"
30+
if _IS_SYNC:
31+
TEST_PATH = os.path.join(Path(__file__).resolve().parent, "retryable_reads/unified")
32+
else:
33+
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "retryable_reads/unified")
2834

2935
# Generate unified tests.
3036
# PyMongo does not support MapReduce, ListDatabaseObjects or ListCollectionObjects.

tools/synchro.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def async_only_test(f: str) -> bool:
221221
"test_raw_bson.py",
222222
"test_read_concern.py",
223223
"test_retryable_reads.py",
224+
"test_retryable_reads_unified.py",
224225
"test_retryable_writes.py",
225226
"test_retryable_writes_unified.py",
226227
"test_session.py",

0 commit comments

Comments
 (0)