Skip to content

Commit 3d0603f

Browse files
committed
Placed the tests in the right location.
Signed-off-by: nbonnin <[email protected]>
1 parent 9ad87d5 commit 3d0603f

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

pandas/tests/frame/test_dtypes.py

+18
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,24 @@ def test_arg_for_errors_in_astype_dictlist(self):
980980

981981
tm.assert_frame_equal(result, expected)
982982

983+
def test_astype_ignores_arg(self):
984+
# 30324
985+
df = pd.DataFrame({"a": [1, 2, 3]})
986+
df_validation = pd.DataFrame({"a": [1, 2, 3]})
987+
988+
# Tests that a KeyError is raised when raise is explicitly declared
989+
with pytest.raises(KeyError):
990+
df.astype({"b": str}, errors="raise")
991+
992+
# Tests that a KeyError is raised when no argument is declared
993+
with pytest.raises(KeyError):
994+
df.astype({"b": str})
995+
996+
# Tests that no KeyError is thrown if ignore is true.
997+
# Ensures there is no change to the initial DataFrame.
998+
df.astype({"b": str}, errors="ignore")
999+
tm.assert_frame_equal(df, df_validation)
1000+
9831001
@pytest.mark.parametrize(
9841002
"input_vals",
9851003
[

pandas/tests/generic/test_generic.py

-18
Original file line numberDiff line numberDiff line change
@@ -947,21 +947,3 @@ def test_axis_classmethods(self, box):
947947
assert obj._get_axis_number(v) == box._get_axis_number(v)
948948
assert obj._get_axis_name(v) == box._get_axis_name(v)
949949
assert obj._get_block_manager_axis(v) == box._get_block_manager_axis(v)
950-
951-
# Tests that the ignore keyword causes the intended functionality
952-
def test_astype_ignores(self):
953-
df = pd.DataFrame({"a": [1, 2, 3]})
954-
df_validation = pd.DataFrame({"a": [1, 2, 3]})
955-
956-
# Tests that a KeyError is raised when raise is explicitly declared
957-
with pytest.raises(KeyError):
958-
df.astype({"b": str}, errors="raise")
959-
960-
# Tests that a KeyError is raised when no argument is declared
961-
with pytest.raises(KeyError):
962-
df.astype({"b": str})
963-
964-
# Tests that no KeyError is thrown if ignore is true.
965-
# Ensures there is no change to the initial DataFrame.
966-
df.astype({"b": str}, errors="ignore")
967-
assert df.equals(df_validation)

0 commit comments

Comments
 (0)