Skip to content

Commit a7d05c6

Browse files
committed
clean up conftest
1 parent 09c6c3e commit a7d05c6

File tree

2 files changed

+12
-56
lines changed

2 files changed

+12
-56
lines changed

bindings/python/test/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import atexit
1514

1615
import pymongo
1716

@@ -41,8 +40,6 @@ def init(self):
4140

4241
if self.connected:
4342
self.client = self.get_client()
44-
atexit.register(self.client.close)
4543

4644

4745
client_context = ClientContext()
48-
client_context.init()

bindings/python/test/conftest.py

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-present MongoDB, Inc.
1+
# Copyright 2025-present MongoDB, Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -11,59 +11,18 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import numpy as np
15-
import pandas as pd
16-
import pytest
17-
18-
# Fixtures for use with Pandas extension types.
19-
20-
21-
@pytest.fixture
22-
def data_for_twos(dtype):
23-
return pd.array(np.ones(100), dtype=dtype)
24-
25-
26-
@pytest.fixture
27-
def na_value():
28-
return np.nan
29-
30-
31-
@pytest.fixture
32-
def na_cmp():
33-
def cmp(a, b):
34-
return np.isnan(a) and np.isnan(b)
35-
36-
return cmp
37-
38-
39-
@pytest.fixture(params=[True, False])
40-
def box_in_series(request):
41-
"""Whether to box the data in a Series"""
42-
return request.param
43-
44-
45-
@pytest.fixture(params=[True, False])
46-
def as_array(request):
47-
"""
48-
Boolean fixture to support ExtensionDtype _from_sequence method testing.
49-
"""
50-
return request.param
14+
from test import client_context
5115

16+
import pytest
5217

53-
@pytest.fixture(params=["ffill", "bfill"])
54-
def fillna_method(request):
55-
"""
56-
Parametrized fixture giving method parameters 'ffill' and 'bfill' for
57-
Series.fillna(method=<method>) testing.
58-
"""
59-
return request.param
18+
pytest_plugins = [
19+
"pandas.tests.extension.conftest",
20+
]
6021

6122

62-
@pytest.fixture
63-
def invalid_scalar(data):
64-
"""
65-
A scalar that *cannot* be held by this ExtensionArray.
66-
The default should work for most subclasses, but is not guaranteed.
67-
If the array can hold any item (i.e. object dtype), then use pytest.skip.
68-
"""
69-
return object.__new__(object)
23+
@pytest.fixture(autouse=True, scope="session")
24+
def client():
25+
client_context.init()
26+
yield
27+
if client_context.client:
28+
client_context.client.close()

0 commit comments

Comments
 (0)