Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pandas/tests/extension/base/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class BaseMissingTests:
_supports_fillna_copy_false = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after defining the attribute, you need to actually use it to determine which version of the test is run


def test_isna(self, data_missing):
expected = np.array([True, False])

Expand Down Expand Up @@ -193,3 +195,9 @@ def test_fillna_fill_other(self, data):
expected = pd.DataFrame({"A": data, "B": [0.0] * len(result)})

tm.assert_frame_equal(result, expected)

def test_fillna_readonly(self, data_missing):
fill_value = data_missing[1]
result = data_missing.fillna(fill_value, copy=False)
expected = data_missing.fillna(fill_value, copy=True)
tm.assert_extension_array_equal(result, expected)
2 changes: 2 additions & 0 deletions pandas/tests/extension/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ def skip_numpy_object(dtype, request):


class TestNumpyExtensionArray(base.ExtensionTests):
_supports_fillna_copy_false = False

@pytest.mark.skip(reason="We don't register our dtype")
# We don't want to register. This test should probably be split in two.
def test_from_dtype(self, data):
Expand Down
15 changes: 0 additions & 15 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,6 @@ def test_isna(self, data_missing):
def test_fillna_no_op_returns_copy(self, data, request):
super().test_fillna_no_op_returns_copy(data)

def test_fillna_readonly(self, data_missing):
# copy keyword is ignored by SparseArray.fillna
# -> copy=True vs False doesn't make a difference
data = data_missing.copy()
data._readonly = True

result = data.fillna(data_missing[1])
assert result[0] == data_missing[1]
tm.assert_extension_array_equal(data, data_missing)

# fillna(copy=False) is ignored -> so same result as above
result = data.fillna(data_missing[1], copy=False)
assert result[0] == data_missing[1]
tm.assert_extension_array_equal(data, data_missing)

@pytest.mark.xfail(reason="Unsupported")
def test_fillna_series(self, data_missing):
# this one looks doable.
Expand Down
Loading