|
18 | 18 | import numpy as np
|
19 | 19 | import pandas as pd
|
20 | 20 | import pandas._testing as tm
|
21 |
| -from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike |
22 |
| -from pandas.tests.extension import base |
| 21 | +import pandas.tests.extension.base |
23 | 22 | import pytest
|
24 | 23 |
|
25 | 24 |
|
26 |
| -class TestJSONArray(base.ExtensionTests): |
| 25 | +class TestJSONArray(pandas.tests.extension.base.ExtensionTests): |
27 | 26 | @pytest.mark.xfail(reason="Unhashable")
|
28 | 27 | def test_value_counts_with_normalize(self, data):
|
29 | 28 | super().test_value_counts_with_normalize(data)
|
@@ -157,9 +156,9 @@ def test_array_interface(self, data):
|
157 | 156 | result = np.array(data, dtype=object)
|
158 | 157 | # Use `json.dumps(x)` instead of passing `x` directly to the super method.
|
159 | 158 | expected = np.array([json.dumps(x) for x in data], dtype=object)
|
160 |
| - if expected.ndim > 1: |
161 |
| - # nested data, explicitly construct as 1D |
162 |
| - expected = construct_1d_object_array_from_listlike(list(data)) |
| 159 | + # if expected.ndim > 1: |
| 160 | + # # nested data, explicitly construct as 1D |
| 161 | + # expected = construct_1d_object_array_from_listlike(list(data)) |
163 | 162 | tm.assert_numpy_array_equal(result, expected)
|
164 | 163 |
|
165 | 164 | @pytest.mark.xfail(reason="Setting a dict as a scalar")
|
@@ -212,6 +211,16 @@ def test_series_constructor_scalar_with_index(self, data, dtype):
|
212 | 211 | expected = pd.Series([scalar], index=["foo"], dtype=dtype)
|
213 | 212 | tm.assert_series_equal(result, expected)
|
214 | 213 |
|
| 214 | + @pytest.mark.xfail(reason="Unhashable") |
| 215 | + def test_getitem_scalar(self, data): |
| 216 | + """ |
| 217 | + `_getitem_` can return any JSON-types objects while `data.dtype.type` returns |
| 218 | + a string to indicate its storage type. |
| 219 | + > assert isinstance(result, data.dtype.type) |
| 220 | + E AssertionError |
| 221 | + """ |
| 222 | + super().test_getitem_scalar() |
| 223 | + |
215 | 224 | # Patching `[....] * len()` to base.BaseSetitemTests because pandas' internals
|
216 | 225 | # has trouble setting sequences of values into scalar positions.
|
217 | 226 |
|
|
0 commit comments