diff --git a/thrift/lib/py3/test/auto_migrate/structs.py b/thrift/lib/py3/test/auto_migrate/structs.py index d5b37d2b323..7df71f5fc77 100644 --- a/thrift/lib/py3/test/auto_migrate/structs.py +++ b/thrift/lib/py3/test/auto_migrate/structs.py @@ -489,3 +489,8 @@ def test_included_struct_const(self) -> None: FANCY_CONST.color_map, {IncludedColour.red: Basic(), IncludedColour.blue: Basic(nom="b")}, ) + + @brokenInAutoMigrate() + def test_instance_base_class(self) -> None: + self.assertTrue(issubclass(Nested1, Struct)) + self.assertIsInstance(Nested1(), Struct) diff --git a/thrift/lib/py3/test/auto_migrate/unions.py b/thrift/lib/py3/test/auto_migrate/unions.py index 0b7f6bb2a78..7ada13fd0a2 100644 --- a/thrift/lib/py3/test/auto_migrate/unions.py +++ b/thrift/lib/py3/test/auto_migrate/unions.py @@ -189,3 +189,8 @@ def test_reserved_union(self) -> None: self.assertEqual(x.type, ReservedUnion.Type.ok) self.assertEqual(x.value, "bar") self.assertEqual(x.ok, "bar") + + @brokenInAutoMigrate() + def test_instance_base_class(self) -> None: + self.assertTrue(issubclass(ComplexUnion, Union)) + self.assertIsInstance(ComplexUnion(tiny=1), Union) diff --git a/thrift/lib/python/test/structs.py b/thrift/lib/python/test/structs.py index e37acceacb8..df40e01c0d7 100644 --- a/thrift/lib/python/test/structs.py +++ b/thrift/lib/python/test/structs.py @@ -71,7 +71,7 @@ to_thrift_set, ) -from thrift.python.types import isset, update_nested_field +from thrift.python.types import isset, Struct, update_nested_field ListT = TypeVar("ListT") SetT = TypeVar("SetT") @@ -701,3 +701,7 @@ def test_compare_optional(self) -> None: with self.assertRaises(TypeError): # TODO(ffrancet): pyre should complain about this z < y # noqa: B015 + + def test_instance_base_class(self) -> None: + self.assertTrue(issubclass(Nested1, Struct)) + self.assertIsInstance(Nested1(), Struct) diff --git a/thrift/lib/python/test/unions.py b/thrift/lib/python/test/unions.py index 06ab37f5a1e..21700b6944e 100644 --- a/thrift/lib/python/test/unions.py +++ b/thrift/lib/python/test/unions.py @@ -322,3 +322,7 @@ def test_union_ordering(self) -> None: # equality y = self.Integers(tiny=4) self.assertEqual(x, y) + + def test_instance_base_class(self) -> None: + self.assertTrue(issubclass(ComplexUnion, Union)) + self.assertIsInstance(ComplexUnion(tiny=1), Union)