Skip to content

Commit

Permalink
Update after code review of unit tests pandas-dev#1478
Browse files Browse the repository at this point in the history
Unit tests for DataFrame.astype merged. Dupliacted those tests for
Series.astype. Both testing deprecation of 'raise_on_error' kwarg.
  • Loading branch information
m-charlton committed Jan 3, 2017
1 parent 39314e6 commit 0ae8550
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 1 addition & 6 deletions pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,19 +523,14 @@ def test_timedeltas(self):
result = df.get_dtype_counts().sort_values()
assert_series_equal(result, expected)

def test_illegal_arg_for_errors_in_astype(self):
def test_arg_for_errors_in_astype(self):
# issue #14878

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

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

def test_depr_kwarg_produces_future_warning(self):
# issue #14878

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

with tm.assert_produces_warning(FutureWarning):
df.astype(np.int8, raise_on_error=False)

Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/series/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,16 @@ def test_complexx(self):
b.real = np.arange(5) + 5
tm.assert_numpy_array_equal(a + 5, b.real)
tm.assert_numpy_array_equal(4 * a, b.imag)

def test_arg_for_errors_in_astype(self):
# issue #14878

sr = Series([1, 2, 3])

with self.assertRaises(ValueError):
sr.astype(np.float64, errors=False)

with tm.assert_produces_warning(FutureWarning):
sr.astype(np.int8, raise_on_error=True)

sr.astype(np.int8, errors='raise')

0 comments on commit 0ae8550

Please sign in to comment.