Skip to content

Commit 4a82fd7

Browse files
committed
Add more tests
1 parent 75d9304 commit 4a82fd7

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

pandas/tests/extension/base/methods.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,10 @@ def test_factorize_equivalence(self, data_for_grouping, na_sentinel):
107107

108108
def test_fillna_copy(self, data_for_fillna):
109109
df = pd.DataFrame({"A": data_for_fillna})
110-
result = df.fillna(0, axis='columns')
110+
filled_val = df.iloc[0,0]
111111

112-
self.assert_frame_equal(df, result)
113-
assert result._is_view
114-
115-
def test_fillna_array_lenght(self, data_for_fillna):
116-
assert len(self) == len(data_for_fillna)
112+
result = df.fillna(filled_val)
113+
assert df.values.base is not result.values.base
117114

118115
def test_combine_le(self, data_repeated):
119116
# GH 20825

pandas/tests/extension/decimal/test_decimal.py

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def data_missing():
2727
return DecimalArray([decimal.Decimal('NaN'), decimal.Decimal(1)])
2828

2929

30+
@pytest.fixture
31+
def data_for_fillna():
32+
return DecimalArray([decimal.Decimal(1), decimal.Decimal(1)])
33+
34+
3035
@pytest.fixture
3136
def data_for_sorting():
3237
return DecimalArray([decimal.Decimal('1'),

pandas/tests/extension/json/test_json.py

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ def data_missing():
4141
return JSONArray([{}, {'a': 10}])
4242

4343

44+
@pytest.fixture
45+
def data_for_fillna():
46+
"""Length 2 array with [Valid, Valid]"""
47+
return JSONArray([{'a': 1}, {'a': 2}])
48+
49+
4450
@pytest.fixture
4551
def data_for_sorting():
4652
return JSONArray([{'b': 1}, {'c': 4}, {'a': 2, 'c': 3}])

pandas/tests/extension/test_categorical.py

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def data_missing():
4646
return Categorical([np.nan, 'A'])
4747

4848

49+
@pytest.fixture
50+
def data_for_fillna():
51+
"""Length 2 array with [Valid, Valid]"""
52+
return Categorical(['A', 'A'])
53+
54+
4955
@pytest.fixture
5056
def data_for_sorting():
5157
return Categorical(['A', 'B', 'C'], categories=['C', 'A', 'B'],

pandas/tests/extension/test_integer.py

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def data_missing(dtype):
4747
return integer_array([np.nan, 1], dtype=dtype)
4848

4949

50+
@pytest.fixture
51+
def data_for_fillna(dtype):
52+
return integer_array([1, 1], dtype=dtype)
53+
54+
5055
@pytest.fixture
5156
def data_for_sorting(dtype):
5257
return integer_array([1, 2, 0], dtype=dtype)

pandas/tests/extension/test_interval.py

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def data_missing():
4747
return IntervalArray.from_tuples([None, (0, 1)])
4848

4949

50+
@pytest.fixture
51+
def data_for_fillna():
52+
"""Length 2 array with [Valid, Valid]"""
53+
return IntervalArray.from_tuples([(1, 1), (1, 2)])
54+
55+
5056
@pytest.fixture
5157
def data_for_sorting():
5258
return IntervalArray.from_tuples([(1, 2), (2, 3), (0, 1)])

pandas/tests/extension/test_sparse.py

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def data_missing(request):
3737
return SparseArray([np.nan, 1], fill_value=request.param)
3838

3939

40+
@pytest.fixture(params=[0, np.nan])
41+
def data_for_fillna(request):
42+
"""Length 2 array with [Valid, Valid]"""
43+
return SparseArray([1, 1], fill_value=request.param)
44+
45+
4046
@pytest.fixture(params=[0, np.nan])
4147
def data_repeated(request):
4248
"""Return different versions of data for count times"""

0 commit comments

Comments
 (0)