Skip to content

Commit 94b9a54

Browse files
authored
PYTHON-5083 Convert test.test_gridfs_spec to async (#2104)
1 parent 01f659c commit 94b9a54

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

test/asynchronous/test_gridfs_spec.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2015-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 AsyncGridFS 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, "gridfs")
32+
else:
33+
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "gridfs")
34+
35+
# Generate unified tests.
36+
globals().update(generate_test_classes(TEST_PATH, module=__name__))
37+
38+
if __name__ == "__main__":
39+
unittest.main()

test/test_gridfs_spec.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@
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__)), "gridfs")
30+
if _IS_SYNC:
31+
TEST_PATH = os.path.join(Path(__file__).resolve().parent, "gridfs")
32+
else:
33+
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "gridfs")
2834

2935
# Generate unified tests.
3036
globals().update(generate_test_classes(TEST_PATH, module=__name__))

tools/synchro.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def async_only_test(f: str) -> bool:
207207
"test_data_lake.py",
208208
"test_encryption.py",
209209
"test_grid_file.py",
210+
"test_gridfs_spec.py",
210211
"test_logger.py",
211212
"test_monitoring.py",
212213
"test_raw_bson.py",

0 commit comments

Comments
 (0)