Skip to content

Commit 0ae8550

Browse files
committed
Update after code review of unit tests pandas-dev#1478
Unit tests for DataFrame.astype merged. Dupliacted those tests for Series.astype. Both testing deprecation of 'raise_on_error' kwarg.
1 parent 39314e6 commit 0ae8550

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pandas/tests/frame/test_dtypes.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -523,19 +523,14 @@ def test_timedeltas(self):
523523
result = df.get_dtype_counts().sort_values()
524524
assert_series_equal(result, expected)
525525

526-
def test_illegal_arg_for_errors_in_astype(self):
526+
def test_arg_for_errors_in_astype(self):
527527
# issue #14878
528528

529529
df = DataFrame([1, 2, 3])
530530

531531
with self.assertRaises(ValueError):
532532
df.astype(np.float64, errors=True)
533533

534-
def test_depr_kwarg_produces_future_warning(self):
535-
# issue #14878
536-
537-
df = DataFrame([1, 2, 3])
538-
539534
with tm.assert_produces_warning(FutureWarning):
540535
df.astype(np.int8, raise_on_error=False)
541536

pandas/tests/series/test_dtypes.py

+13
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,16 @@ def test_complexx(self):
168168
b.real = np.arange(5) + 5
169169
tm.assert_numpy_array_equal(a + 5, b.real)
170170
tm.assert_numpy_array_equal(4 * a, b.imag)
171+
172+
def test_arg_for_errors_in_astype(self):
173+
# issue #14878
174+
175+
sr = Series([1, 2, 3])
176+
177+
with self.assertRaises(ValueError):
178+
sr.astype(np.float64, errors=False)
179+
180+
with tm.assert_produces_warning(FutureWarning):
181+
sr.astype(np.int8, raise_on_error=True)
182+
183+
sr.astype(np.int8, errors='raise')

0 commit comments

Comments
 (0)