-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reserved names for message types
Unfortunately, our tests missed this, because all our tests with reserved names for message types also had reserved names for the identifiers. Added a couple tests for the new scenario, reproed, and fixed by replacing such instances with `Any` (best we can do) Fixes #221
- Loading branch information
1 parent
02378ee
commit 814ddd6
Showing
6 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import six | ||
|
||
from google.protobuf.descriptor import FieldDescriptor | ||
from google.protobuf.message import Message | ||
|
||
import testproto.test_pb2 as test_pb2 | ||
from testproto.reexport_pb2 import ( | ||
|
@@ -476,3 +477,11 @@ def test_casttype(): | |
s.email = Email("[email protected]") | ||
assert s.email == "[email protected]" | ||
s.email_by_uid[UserId(33)] = Email("[email protected]") | ||
|
||
def test_access_message_with_python_keyword_name(): | ||
# type: () -> None | ||
with pytest.raises(AttributeError, match="module 'testproto.test_pb2' has no attribute 'asdf'"): | ||
getattr(test_pb2, "asdf") | ||
msg_cls = getattr(test_pb2, "None") | ||
none = msg_cls() | ||
assert isinstance(none, Message) |