Skip to content

Commit

Permalink
Remove descriptor_test_wrapper for python's descriptor_test.
Browse files Browse the repository at this point in the history
The test wrappers were another way to document nonconformant behaviour between
different python backends. We can achieve the same by removing the wrapper
script and adding an if-condition in the test itself based on
api_implementation.Type(). Since we already do that for nonconformance between
pure Python vs. C++ backends, this change makes it easier to look for UPB
nonconformance instead of going through another layer of indirection.

PiperOrigin-RevId: 700829382
  • Loading branch information
tonyliaoss authored and copybara-github committed Nov 28, 2024
1 parent d59a9e1 commit cbecd9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 44 deletions.
18 changes: 15 additions & 3 deletions python/google/protobuf/internal/descriptor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ def testFileDescriptor(self):

@unittest.skipIf(
api_implementation.Type() == 'python',
'Immutability of descriptors is only enforced in v2 implementation')
'Immutability of descriptors is only enforced in c++ and upb backends',
)
def testImmutableCppDescriptor(self):
file_descriptor = unittest_pb2.DESCRIPTOR
message_descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR
Expand All @@ -568,8 +569,19 @@ def testImmutableCppDescriptor(self):
enum_descriptor.has_options = False
with self.assertRaises(AttributeError) as e:
message_descriptor.has_options = True
self.assertEqual('attribute is not writable: has_options',
str(e.exception))

if api_implementation.Type() == 'cpp':
self.assertEqual(
'attribute is not writable: has_options', str(e.exception)
)
else:
self.assertEqual(api_implementation.Type(), 'upb')
self.assertEqual(
"attribute 'has_options' of "
"'google._upb._message.Descriptor' "
'objects is not writable',
str(e.exception),
)

def testDefault(self):
message_descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR
Expand Down
2 changes: 0 additions & 2 deletions python/pb_unit_tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ licenses(["notice"])

pyproto_test_wrapper(name = "descriptor_pool_test")

pyproto_test_wrapper(name = "descriptor_test")

pyproto_test_wrapper(name = "generator_test")

pyproto_test_wrapper(name = "proto_builder_test")
Expand Down
39 changes: 0 additions & 39 deletions python/pb_unit_tests/descriptor_test_wrapper.py

This file was deleted.

0 comments on commit cbecd9d

Please sign in to comment.