Skip to content

Commit 8262133

Browse files
author
analyticalmonk
committed
wrote test representing bug fix result for pandas-dev#15520
1 parent d16cce8 commit 8262133

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/dtypes/test_common.py

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
import numpy as np
5+
import pandas as pd
56

67
from pandas.core.dtypes.dtypes import (
78
DatetimeTZDtype, PeriodDtype, CategoricalDtype)
@@ -13,6 +14,15 @@
1314

1415
class TestPandasDtype(tm.TestCase):
1516

17+
# Passing invalid dtype, both as a string or object, must raise TypeError
18+
def test_invalid_dtype_error(self):
19+
msg = 'not understood'
20+
with tm.assertRaisesRegexp(TypeError, msg):
21+
pandas_dtype(pd.Timestamp)
22+
23+
with tm.assertRaisesRegexp(TypeError, msg):
24+
pandas_dtype('time')
25+
1626
def test_numpy_dtype(self):
1727
for dtype in ['M8[ns]', 'm8[ns]', 'object', 'float64', 'int64']:
1828
self.assertEqual(pandas_dtype(dtype), np.dtype(dtype))

0 commit comments

Comments
 (0)