Skip to content

Commit 8ae9a04

Browse files
PYTHON-5102 Convert test.test_server_selection_logging to async (#2121)
Co-authored-by: Noah Stapp <noah@noahstapp.com>
1 parent 2c49215 commit 8ae9a04

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2024-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+
"""Run the server selection logging unified format 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, "server_selection_logging")
32+
else:
33+
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "server_selection_logging")
34+
35+
36+
globals().update(
37+
generate_test_classes(
38+
TEST_PATH,
39+
module=__name__,
40+
)
41+
)
42+
43+
44+
if __name__ == "__main__":
45+
unittest.main()

test/test_server_selection_logging.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@
1717

1818
import os
1919
import sys
20+
from pathlib import Path
2021

2122
sys.path[0:0] = [""]
2223

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 = os.path.join(os.path.dirname(os.path.realpath(__file__)), "server_selection_logging")
30+
if _IS_SYNC:
31+
TEST_PATH = os.path.join(Path(__file__).resolve().parent, "server_selection_logging")
32+
else:
33+
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "server_selection_logging")
2834

2935

3036
globals().update(
3137
generate_test_classes(
32-
_TEST_PATH,
38+
TEST_PATH,
3339
module=__name__,
3440
)
3541
)

tools/synchro.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def async_only_test(f: str) -> bool:
227227
"test_retryable_writes.py",
228228
"test_retryable_writes_unified.py",
229229
"test_run_command.py",
230+
"test_server_selection_logging.py",
230231
"test_session.py",
231232
"test_server_selection_rtt.py",
232233
"test_sessions_unified.py",

0 commit comments

Comments
 (0)