From 6c5086d1be8baa586b1ad13fb5583a42fd1acbba Mon Sep 17 00:00:00 2001 From: Isaac Virshup Date: Tue, 31 Oct 2023 15:15:11 +0000 Subject: [PATCH] Add tests --- pandas/tests/frame/test_subclass.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pandas/tests/frame/test_subclass.py b/pandas/tests/frame/test_subclass.py index 55bfefaeb53a9..7fa1ab56ae225 100644 --- a/pandas/tests/frame/test_subclass.py +++ b/pandas/tests/frame/test_subclass.py @@ -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)