Skip to content

Commit 1e4ff80

Browse files
committed
TST: Added tests for pandas object ensure type (pandas-dev#31925)
1 parent f2c3eab commit 1e4ff80

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

pandas/tests/base/test_base.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
3+
from pandas.core.base import PandasObject
4+
5+
pandas_object = PandasObject()
6+
7+
8+
class SubclassPandasObject(PandasObject):
9+
pass
10+
11+
12+
subclass_pandas_object = SubclassPandasObject()
13+
14+
15+
@pytest.mark.parametrize("other_object", [pandas_object, subclass_pandas_object])
16+
def test_pandas_object_ensure_type(other_object):
17+
pandas_object = PandasObject()
18+
assert pandas_object._ensure_type(other_object)
19+
20+
21+
def test_pandas_object_ensure_type_for_same_object():
22+
pandas_object_a = PandasObject()
23+
pandas_object_b = pandas_object_a
24+
assert pandas_object_a._ensure_type(pandas_object_b)
25+
26+
27+
class OtherClass:
28+
pass
29+
30+
31+
other_class = OtherClass()
32+
33+
34+
@pytest.mark.parametrize("other_object", [other_class])
35+
def test_pandas_object_ensure_type_for_false(other_object):
36+
pandas_object = PandasObject()
37+
with pytest.raises(AssertionError):
38+
assert pandas_object._ensure_type(other_object)

0 commit comments

Comments
 (0)