1# Copyright 2018 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import proto 16 17 18PACKAGE = "a.test.package.with.and.without.manifest" 19__protobuf__ = proto.module(package=PACKAGE, manifest={"This", "That"},) 20 21 22class This(proto.Message): 23 this = proto.Field(proto.INT32, number=1) 24 25 26class That(proto.Message): 27 that = proto.Field(proto.INT32, number=1) 28 29 30class NotInManifest(proto.Message): 31 them = proto.Field(proto.INT32, number=1) 32 33 34def test_manifest_causes_exclusion_of_classname_salt(): 35 36 assert ( 37 This.pb(This()).DESCRIPTOR.file.name 38 == "test_message_filename_with_and_without_manifest.proto" 39 ) 40 assert ( 41 That.pb(That()).DESCRIPTOR.file.name 42 == "test_message_filename_with_and_without_manifest.proto" 43 ) 44 45 assert ( 46 NotInManifest.pb(NotInManifest()).DESCRIPTOR.file.name 47 == "test_message_filename_with_and_without_manifest_" 48 + PACKAGE 49 + ".notinmanifest.proto" 50 ) 51