Skip to content

Commit

Permalink
Delete old conformance test hack
Browse files Browse the repository at this point in the history
This is no longer relevant, and all 3 python implementations are conformant in JSON and binary formats

PiperOrigin-RevId: 705214440
  • Loading branch information
mkruskal-google authored and copybara-github committed Dec 11, 2024
1 parent 2598c6d commit b9cb184
Showing 1 changed file with 2 additions and 56 deletions.
58 changes: 2 additions & 56 deletions conformance/conformance_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,64 +48,10 @@ def _create_test_message(type):
def do_test(request):
response = conformance_pb2.ConformanceResponse()

if request.message_type == "conformance.FailureSet":
failure_set = conformance_pb2.FailureSet()
failures = []
# TODO: Remove, this is a hack to detect if the old vs new
# parser is used by the cpp code. Relying on a bug in the old parser.
hack_proto = test_messages_proto2_pb2.TestAllTypesProto2()
old_parser = True
try:
hack_proto.ParseFromString(b"\322\002\001")
except message.DecodeError as e:
old_parser = False
if old_parser:
# the string above is one of the failing conformance test strings of the
# old parser. If we succeed the c++ implementation is using the old
# parser so we add the list of failing conformance tests.
failures = [
"Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.DOUBLE",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FLOAT",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64",
"Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.DOUBLE",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FLOAT",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64",
]
for x in failures:
failure_set.test.append(conformance_pb2.TestStatus(name=x))
response.protobuf_payload = failure_set.SerializeToString()
return response

isJson = request.WhichOneof("payload") == "json_payload"
is_json = request.WhichOneof("payload") == "json_payload"
test_message = _create_test_message(request.message_type)

if (not isJson) and (test_message is None):
if (not is_json) and (test_message is None):
raise ProtocolError("Protobuf request doesn't have specific payload type")

try:
Expand Down

0 comments on commit b9cb184

Please sign in to comment.