Python google.protobuf.text_format.ParseLines() Examples

The following are code examples for showing how to use google.protobuf.text_format.ParseLines(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: text_format_test.py    MIT License 6 votes vote down vote up
def testMapOrderSemantics(self):
    golden_lines = self.ReadGolden('map_test_data.txt')
    # The C++ implementation emits defaulted-value fields, while the Python
    # implementation does not.  Adjusting for this is awkward, but it is
    # valuable to test against a common golden file.
    line_blacklist = ('  key: 0\n', '  value: 0\n', '  key: false\n',
                      '  value: false\n')
    golden_lines = [line for line in golden_lines if line not in line_blacklist]

    message = map_unittest_pb2.TestMap()
    text_format.ParseLines(golden_lines, message)
    candidate = text_format.MessageToString(message)
    # The Python implementation emits "1.0" for the double value that the C++
    # implementation emits as "1".
    candidate = candidate.replace('1.0', '1', 2)
    self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 2
Project: syndicate-core   Author: syndicate-storage   File: text_format_test.py    Apache License 2.0 6 votes vote down vote up
def testMapOrderSemantics(self):
    golden_lines = self.ReadGolden('map_test_data.txt')
    # The C++ implementation emits defaulted-value fields, while the Python
    # implementation does not.  Adjusting for this is awkward, but it is
    # valuable to test against a common golden file.
    line_blacklist = ('  key: 0\n', '  value: 0\n', '  key: false\n',
                      '  value: false\n')
    golden_lines = [line for line in golden_lines if line not in line_blacklist]

    message = map_unittest_pb2.TestMap()
    text_format.ParseLines(golden_lines, message)
    candidate = text_format.MessageToString(message)
    # The Python implementation emits "1.0" for the double value that the C++
    # implementation emits as "1".
    candidate = candidate.replace('1.0', '1', 2)
    self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 3
Project: kastodi   Author: kharts   File: text_format_test.py    GNU General Public License v2.0 6 votes vote down vote up
def testMapOrderSemantics(self):
    golden_lines = self.ReadGolden('map_test_data.txt')
    # The C++ implementation emits defaulted-value fields, while the Python
    # implementation does not.  Adjusting for this is awkward, but it is
    # valuable to test against a common golden file.
    line_blacklist = ('  key: 0\n',
                      '  value: 0\n',
                      '  key: false\n',
                      '  value: false\n')
    golden_lines = [line for line in golden_lines if line not in line_blacklist]

    message = map_unittest_pb2.TestMap()
    text_format.ParseLines(golden_lines, message)
    candidate = text_format.MessageToString(message)
    # The Python implementation emits "1.0" for the double value that the C++
    # implementation emits as "1".
    candidate = candidate.replace('1.0', '1', 2)
    self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 4
Project: bigquerylayers   Author: smandaric   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromBytesFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.BytesIO(self._BYTES_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 5
Project: bigquerylayers   Author: smandaric   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromUnicodeFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.StringIO(self._UNICODE_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 6
Project: bigquerylayers   Author: smandaric   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromBytesLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._BYTES_SAMPLE.split(b'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 7
Project: bigquerylayers   Author: smandaric   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromUnicodeLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._UNICODE_SAMPLE.split(u'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 8
Project: bigquerylayers   Author: smandaric   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 9
Project: FUTU_Stop_Loss   Author: BigtoC   File: text_format_test.py    MIT License 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 10
Project: FUTU_Stop_Loss   Author: BigtoC   File: text_format_test.py    MIT License 5 votes vote down vote up
def testMapOrderEnforcement(self):
    message = map_unittest_pb2.TestMap()
    for letter in string.ascii_uppercase[13:26]:
      message.map_string_string[letter] = 'dummy'
    for letter in reversed(string.ascii_uppercase[0:13]):
      message.map_string_string[letter] = 'dummy'
    golden = ''.join(('map_string_string {\n  key: "%c"\n  value: "dummy"\n}\n'
                      % (letter,) for letter in string.ascii_uppercase))
    self.CompareToGoldenText(text_format.MessageToString(message), golden)

  # TODO(teboring): In c/137553523, not serializing default value for map entry
  # message has been fixed. This test needs to be disabled in order to submit
  # that cl. Add this back when c/137553523 has been submitted.
  # def testMapOrderSemantics(self):
  #   golden_lines = self.ReadGolden('map_test_data.txt')

  #   message = map_unittest_pb2.TestMap()
  #   text_format.ParseLines(golden_lines, message)
  #   candidate = text_format.MessageToString(message)
  #   # The Python implementation emits "1.0" for the double value that the C++
  #   # implementation emits as "1".
  #   candidate = candidate.replace('1.0', '1', 2)
  #   candidate = candidate.replace('0.0', '0', 2)
  #   self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 11
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: text_format_test.py    MIT License 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 12
Project: chrome_os_updater   Author: MuntashirAkon   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromBytesFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.BytesIO(self._BYTES_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 13
Project: chrome_os_updater   Author: MuntashirAkon   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromUnicodeFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.StringIO(self._UNICODE_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 14
Project: chrome_os_updater   Author: MuntashirAkon   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromBytesLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._BYTES_SAMPLE.split(b'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 15
Project: chrome_os_updater   Author: MuntashirAkon   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromUnicodeLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._UNICODE_SAMPLE.split(u'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 16
Project: chrome_os_updater   Author: MuntashirAkon   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 17
Project: poker   Author: surgebiswas   File: text_format_test.py    MIT License 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 18
Project: poker   Author: surgebiswas   File: text_format_test.py    MIT License 5 votes vote down vote up
def testMapOrderEnforcement(self):
    message = map_unittest_pb2.TestMap()
    for letter in string.ascii_uppercase[13:26]:
      message.map_string_string[letter] = 'dummy'
    for letter in reversed(string.ascii_uppercase[0:13]):
      message.map_string_string[letter] = 'dummy'
    golden = ''.join(('map_string_string {\n  key: "%c"\n  value: "dummy"\n}\n'
                      % (letter,) for letter in string.ascii_uppercase))
    self.CompareToGoldenText(text_format.MessageToString(message), golden)

  # TODO(teboring): In c/137553523, not serializing default value for map entry
  # message has been fixed. This test needs to be disabled in order to submit
  # that cl. Add this back when c/137553523 has been submitted.
  # def testMapOrderSemantics(self):
  #   golden_lines = self.ReadGolden('map_test_data.txt')

  #   message = map_unittest_pb2.TestMap()
  #   text_format.ParseLines(golden_lines, message)
  #   candidate = text_format.MessageToString(message)
  #   # The Python implementation emits "1.0" for the double value that the C++
  #   # implementation emits as "1".
  #   candidate = candidate.replace('1.0', '1', 2)
  #   candidate = candidate.replace('0.0', '0', 2)
  #   self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 19
Project: syndicate-core   Author: syndicate-storage   File: text_format_test.py    Apache License 2.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 20
Project: Emotion-Evaluator   Author: Attriumph   File: text_format_test.py    MIT License 5 votes vote down vote up
def testFromBytesFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.BytesIO(self._BYTES_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 21
Project: Emotion-Evaluator   Author: Attriumph   File: text_format_test.py    MIT License 5 votes vote down vote up
def testFromUnicodeFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.StringIO(self._UNICODE_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 22
Project: Emotion-Evaluator   Author: Attriumph   File: text_format_test.py    MIT License 5 votes vote down vote up
def testFromBytesLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._BYTES_SAMPLE.split(b'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 23
Project: Emotion-Evaluator   Author: Attriumph   File: text_format_test.py    MIT License 5 votes vote down vote up
def testFromUnicodeLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._UNICODE_SAMPLE.split(u'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 24
Project: Emotion-Evaluator   Author: Attriumph   File: text_format_test.py    MIT License 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 25
Project: geofire-python   Author: ininex   File: text_format_test.py    MIT License 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 26
Project: geofire-python   Author: ininex   File: text_format_test.py    MIT License 5 votes vote down vote up
def testMapOrderEnforcement(self):
    message = map_unittest_pb2.TestMap()
    for letter in string.ascii_uppercase[13:26]:
      message.map_string_string[letter] = 'dummy'
    for letter in reversed(string.ascii_uppercase[0:13]):
      message.map_string_string[letter] = 'dummy'
    golden = ''.join(('map_string_string {\n  key: "%c"\n  value: "dummy"\n}\n'
                      % (letter,) for letter in string.ascii_uppercase))
    self.CompareToGoldenText(text_format.MessageToString(message), golden)

  # TODO(teboring): In c/137553523, not serializing default value for map entry
  # message has been fixed. This test needs to be disabled in order to submit
  # that cl. Add this back when c/137553523 has been submitted.
  # def testMapOrderSemantics(self):
  #   golden_lines = self.ReadGolden('map_test_data.txt')

  #   message = map_unittest_pb2.TestMap()
  #   text_format.ParseLines(golden_lines, message)
  #   candidate = text_format.MessageToString(message)
  #   # The Python implementation emits "1.0" for the double value that the C++
  #   # implementation emits as "1".
  #   candidate = candidate.replace('1.0', '1', 2)
  #   candidate = candidate.replace('0.0', '0', 2)
  #   self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 27
Project: go2mapillary   Author: enricofer   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 28
Project: go2mapillary   Author: enricofer   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testMapOrderEnforcement(self):
    message = map_unittest_pb2.TestMap()
    for letter in string.ascii_uppercase[13:26]:
      message.map_string_string[letter] = 'dummy'
    for letter in reversed(string.ascii_uppercase[0:13]):
      message.map_string_string[letter] = 'dummy'
    golden = ''.join(('map_string_string {\n  key: "%c"\n  value: "dummy"\n}\n'
                      % (letter,) for letter in string.ascii_uppercase))
    self.CompareToGoldenText(text_format.MessageToString(message), golden)

  # TODO(teboring): In c/137553523, not serializing default value for map entry
  # message has been fixed. This test needs to be disabled in order to submit
  # that cl. Add this back when c/137553523 has been submitted.
  # def testMapOrderSemantics(self):
  #   golden_lines = self.ReadGolden('map_test_data.txt')

  #   message = map_unittest_pb2.TestMap()
  #   text_format.ParseLines(golden_lines, message)
  #   candidate = text_format.MessageToString(message)
  #   # The Python implementation emits "1.0" for the double value that the C++
  #   # implementation emits as "1".
  #   candidate = candidate.replace('1.0', '1', 2)
  #   candidate = candidate.replace('0.0', '0', 2)
  #   self.assertMultiLineEqual(candidate, ''.join(golden_lines))


# Tests of proto2-only features (MessageSet, extensions, etc.). 
Example 29
Project: kastodi   Author: kharts   File: text_format_test.py    GNU General Public License v2.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 30
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromBytesFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.BytesIO(self._BYTES_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 31
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromUnicodeFile(self, message_module):
    m = message_module.TestAllTypes()
    f = io.StringIO(self._UNICODE_SAMPLE)
    text_format.ParseLines(f, m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 32
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromBytesLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._BYTES_SAMPLE.split(b'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 33
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testFromUnicodeLines(self, message_module):
    m = message_module.TestAllTypes()
    text_format.ParseLines(self._UNICODE_SAMPLE.split(u'\n'), m)
    self.assertEqual(m.optional_bytes, self._GOLDEN_BYTES)
    self.assertEqual(m.optional_string, self._GOLDEN_UNICODE)
    self.assertEqual(m.repeated_bytes[0], self._GOLDEN_BYTES) 
Example 34
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: text_format_test.py    GNU General Public License v3.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEqual(message, parsed_message) 
Example 35
Project: weilai   Author: cherrishes   File: text_format_test.py    Apache License 2.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEquals(message, parsed_message) 
Example 36
Project: weilai   Author: cherrishes   File: text_format_test.py    Apache License 2.0 5 votes vote down vote up
def testParseLinesGolden(self):
    opened = self.ReadGolden('text_format_unittest_data.txt')
    parsed_message = unittest_pb2.TestAllTypes()
    r = text_format.ParseLines(opened, parsed_message)
    self.assertIs(r, parsed_message)

    message = unittest_pb2.TestAllTypes()
    test_util.SetAllFields(message)
    self.assertEquals(message, parsed_message)