Fix python and kotlin tests

pull/9461/head
Deanna Garcia 3 years ago
parent 349738dde5
commit fc9fb726f1
  1. 1
      CHANGES.txt
  2. 26
      python/google/protobuf/internal/json_format_test.py
  3. 16
      src/google/protobuf/compiler/java/java_message.cc
  4. 16
      src/google/protobuf/compiler/java/java_message_lite.cc

@ -23,7 +23,6 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
* Fix initialization bug in doc comment line numbers
Kotlin
* Enhancements to Kotlin support for Any protobuf.
* Add orNull extensions for optional message fields in Kotlin.
Python

@ -1049,14 +1049,8 @@ class JsonFormatTest(JsonFormatBase):
def testInvalidTimestamp(self):
message = json_format_proto3_pb2.TestTimestamp()
text = '{"value": "10000-01-01T00:00:00.00Z"}'
<<<<<<< HEAD
self.assertRaisesRegex(
json_format.ParseError,
'Failed to parse value field: '
=======
self.assertRaisesRegexp(
json_format.ParseError, 'Failed to parse value field: '
>>>>>>> refs/tags/sync-piper
'time data \'10000-01-01T00:00:00\' does not match'
' format \'%Y-%m-%dT%H:%M:%S\' at TestTimestamp.value.',
json_format.Parse, text, message)
@ -1095,16 +1089,9 @@ class JsonFormatTest(JsonFormatBase):
def testInvalidOneof(self):
message = json_format_proto3_pb2.TestOneof()
text = '{"oneofInt32Value": 1, "oneofStringValue": "2"}'
<<<<<<< HEAD
self.assertRaisesRegex(
json_format.ParseError,
'Message type "proto3.TestOneof"'
' should not have multiple "oneof_value" oneof fields.',
=======
self.assertRaisesRegexp(
json_format.ParseError, 'Message type "proto3.TestOneof"'
' should not have multiple "oneof_value" oneof fields at "TestOneof".',
>>>>>>> refs/tags/sync-piper
json_format.Parse, text, message)
def testInvalidListValue(self):
@ -1167,18 +1154,6 @@ class JsonFormatTest(JsonFormatBase):
'value',
json_format.Parse, text, message)
text = '{"value": 1234}'
<<<<<<< HEAD
self.assertRaisesRegex(
json_format.ParseError,
'@type is missing when parsing any message.',
json_format.Parse, text, message)
text = '{"@type": "type.googleapis.com/MessageNotExist", "value": 1234}'
self.assertRaisesRegex(
TypeError,
'Can not find message descriptor by type_url: '
'type.googleapis.com/MessageNotExist.',
json_format.Parse, text, message)
=======
self.assertRaisesRegex(json_format.ParseError,
'@type is missing when parsing any message at Any',
json_format.Parse, text, message)
@ -1187,7 +1162,6 @@ class JsonFormatTest(JsonFormatBase):
json_format.ParseError, 'Can not find message descriptor by type_url: '
'type.googleapis.com/MessageNotExist at Any', json_format.Parse, text,
message)
>>>>>>> refs/tags/sync-piper
# Only last part is to be used: b/25630112
text = (r'{"@type": "incorrect.googleapis.com/google.protobuf.Int32Value",'
r'"value": 1234}')

@ -1526,7 +1526,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
"public operator fun <T : Any> get(extension: "
"public operator fun <T> get(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
@ -1542,7 +1542,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
"public operator fun <E : Any> get(\n"
"public operator fun <E> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@ -1571,7 +1571,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.PublishedApi\n"
"internal fun <T : Any> setExtension(extension: "
"internal fun <T> setExtension(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>, "
"value: T) {\n"
" _builder.setExtension(extension, value)\n"
@ -1614,7 +1614,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"public fun <E : Any> com.google.protobuf.kotlin.ExtensionList<E, "
"public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@ -1623,7 +1623,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
"public inline operator fun <E : Any> "
"public inline operator fun <E> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@ -1633,7 +1633,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"public fun <E : Any> com.google.protobuf.kotlin.ExtensionList<E, "
"public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@ -1644,7 +1644,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
"public inline operator fun <E : Any> "
"public inline operator fun <E> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@ -1654,7 +1654,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"public operator fun <E : Any> "
"public operator fun <E> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"

@ -847,7 +847,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
"public operator fun <T : Any> get(extension: "
"public operator fun <T> get(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
@ -863,7 +863,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
"public operator fun <E : Any> get(\n"
"public operator fun <E> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@ -892,7 +892,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.PublishedApi\n"
"internal fun <T : Any> setExtension(extension: "
"internal fun <T> setExtension(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>, "
"value: T) {\n"
" _builder.setExtension(extension, value)\n"
@ -935,7 +935,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"public fun<E : Any> com.google.protobuf.kotlin.ExtensionList<E, "
"public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@ -944,7 +944,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
"public inline operator fun <E : Any> "
"public inline operator fun <E> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@ -954,7 +954,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"public fun<E : Any> com.google.protobuf.kotlin.ExtensionList<E, "
"public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@ -965,7 +965,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
"public inline operator fun <E : Any> "
"public inline operator fun <E> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@ -975,7 +975,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"public operator fun <E : Any> "
"public operator fun <E> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"

Loading…
Cancel
Save