Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivirshup committed Oct 31, 2023
1 parent 47bb5de commit 6c5086d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pandas/tests/frame/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,3 +773,21 @@ def test_constructor_with_metadata():
)
subset = df[["A", "B"]]
assert isinstance(subset, MySubclassWithMetadata)


class SimpleSubClass(DataFrame):
"""A subclass of DataFrame that does not define a constructor."""


class TestSubclassWithoutConstructor:
def test_copy(self):
expected = DataFrame({"a": [1, 2, 3]})
result = SimpleSubClass(expected).copy()

tm.assert_frame_equal(result, expected)

def test_groupby(self):
df = SimpleSubClass(DataFrame({"a": [1, 2, 3]}))

for _, v in df.groupby("a"):
assert isinstance(v, DataFrame)

0 comments on commit 6c5086d

Please sign in to comment.