Skip to content

In tests, explore creating descriptors from strings rather than helper functions to improve readability #1986

@parthea

Description

@parthea

From #1975 (comment) in PR #1975,

See suggestion below to improve readability of tests that require building descriptors from protos.

If it's trivial to read from a proto "file" (string) in tests, it might be simpler to simply encode the protofile inline rather than calling make_file_pb2

Something like this

proto_descriptor = make_protodescriptor("""
package xx;

message Foo { 
  string foo = 1;
}
""")

instead of

    fd = (
        make_file_pb2(
            name="someexample.proto",
            package="google.example.v1beta1",
            messages=(
                make_message_pb2(name="ExampleRequest", fields=fields),
                make_message_pb2(name="ExampleResponse", fields=()),
            ),
            services=(
                descriptor_pb2.ServiceDescriptorProto(
                    name="SomeExample",

would improve readability

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: cleanupAn internal cleanup or hygiene concern.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions