本文整理匯總了Python中google.protobuf.unittest_pb2.TestOneof2方法的典型用法代碼示例。如果您正苦於以下問題:Python unittest_pb2.TestOneof2方法的具體用法?Python unittest_pb2.TestOneof2怎麽用?Python unittest_pb2.TestOneof2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.protobuf.unittest_pb2
的用法示例。
在下文中一共展示了unittest_pb2.TestOneof2方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testDisconnectingInOneof
# 需要導入模塊: from google.protobuf import unittest_pb2 [as 別名]
# 或者: from google.protobuf.unittest_pb2 import TestOneof2 [as 別名]
def testDisconnectingInOneof(self):
m = unittest_pb2.TestOneof2() # This message has two messages in a oneof.
m.foo_message.qux_int = 5
sub_message = m.foo_message
# Accessing another message's field does not clear the first one
self.assertEqual(m.foo_lazy_message.qux_int, 0)
self.assertEqual(m.foo_message.qux_int, 5)
# But mutating another message in the oneof detaches the first one.
m.foo_lazy_message.qux_int = 6
self.assertEqual(m.foo_message.qux_int, 0)
# The reference we got above was detached and is still valid.
self.assertEqual(sub_message.qux_int, 5)
sub_message.qux_int = 7