Skip to content

Commit

Permalink
Protobuf usage clean up
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 554714188
  • Loading branch information
anandolee authored and copybara-github committed Aug 8, 2023
1 parent da9f1c4 commit 4715158
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pybind11_protobuf/tests/extension_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from absl.testing import absltest
from absl.testing import parameterized

from google.protobuf import unknown_fields
from google.protobuf.internal import api_implementation
from pybind11_protobuf.tests import extension_in_other_file_in_deps_pb2
from pybind11_protobuf.tests import extension_in_other_file_pb2
Expand Down Expand Up @@ -179,8 +180,8 @@ def test_reserialize_allow_unknown_inner(self):
a = get_allow_unknown_inner(96)
b = m.reserialize_allow_unknown_inner(a)
if api_implementation.Type() == 'cpp':
self.assertLen(b.UnknownFields(), 1)
self.assertEqual(2001, b.UnknownFields()[0].field_number)
self.assertLen(unknown_fields.UnknownFieldSet(b), 1)
self.assertEqual(2001, unknown_fields.UnknownFieldSet(b)[0].field_number)
else:
b_value = b.Extensions[
extension_in_other_file_pb2.AllowUnknownInnerExtension.hook].value
Expand All @@ -190,8 +191,9 @@ def test_reserialize_allow_unknown_outer(self):
a = extension_pb2.AllowUnknownOuter(inner=get_allow_unknown_inner(97))
b = m.reserialize_allow_unknown_outer(a)
if api_implementation.Type() == 'cpp':
self.assertLen(b.inner.UnknownFields(), 1)
self.assertEqual(2001, b.inner.UnknownFields()[0].field_number)
self.assertLen(unknown_fields.UnknownFieldSet(b.inner), 1)
self.assertEqual(
2001, unknown_fields.UnknownFieldSet(b.inner)[0].field_number)
else:
b_inner_value = b.inner.Extensions[
extension_in_other_file_pb2.AllowUnknownInnerExtension.hook].value
Expand Down

0 comments on commit 4715158

Please sign in to comment.