Skip to content

Commit 87dafda

Browse files
committed
TST: Adds tests for warning behavior on set on nonexistent attr
1 parent 881e434 commit 87dafda

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/dtypes/test_generic.py

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import pandas as pd
66
from pandas.core.dtypes import generic as gt
7+
import pytest
78

89

910
class TestABCClasses(object):
@@ -17,6 +18,7 @@ class TestABCClasses(object):
1718
df = pd.DataFrame({'names': ['a', 'b', 'c']}, index=multi_index)
1819
sparse_series = pd.Series([1, 2, 3]).to_sparse()
1920
sparse_array = pd.SparseArray(np.random.randn(10))
21+
series = pd.Series([1, 2, 3])
2022

2123
def test_abc_types(self):
2224
assert isinstance(pd.Index(['a', 'b', 'c']), gt.ABCIndex)
@@ -38,3 +40,8 @@ def test_abc_types(self):
3840
assert isinstance(self.sparse_array, gt.ABCSparseArray)
3941
assert isinstance(self.categorical, gt.ABCCategorical)
4042
assert isinstance(pd.Period('2012', freq='A-DEC'), gt.ABCPeriod)
43+
with catch_warnings(record=True) as w:
44+
self.series.not_an_index = [1, 2]
45+
assert len(w) == 0 # fail if false warning on Series
46+
with pytest.warns(UserWarning):
47+
self.df.not_a_column = [1, 2]

0 commit comments

Comments
 (0)