diff options
Diffstat (limited to 'python/tests')
| -rw-r--r-- | python/tests/proto_pkg_path/Android.bp | 13 | ||||
| -rw-r--r-- | python/tests/proto_pkg_path/main.py | 18 | ||||
| -rw-r--r-- | python/tests/proto_pkg_path/proto/common.proto | 5 | ||||
| -rw-r--r-- | python/tests/proto_pkg_path/proto/test.proto | 8 |
4 files changed, 44 insertions, 0 deletions
diff --git a/python/tests/proto_pkg_path/Android.bp b/python/tests/proto_pkg_path/Android.bp new file mode 100644 index 000000000..17afde2aa --- /dev/null +++ b/python/tests/proto_pkg_path/Android.bp @@ -0,0 +1,13 @@ +python_test_host { + name: "py_proto_pkg_path_test", + main: "main.py", + srcs: [ + "main.py", + "proto/*.proto", + ], + pkg_path: "mylib/subpackage", + proto: { + canonical_path_from_root: false, + respect_pkg_path: true, + }, +} diff --git a/python/tests/proto_pkg_path/main.py b/python/tests/proto_pkg_path/main.py new file mode 100644 index 000000000..c4acddef5 --- /dev/null +++ b/python/tests/proto_pkg_path/main.py @@ -0,0 +1,18 @@ +import sys + +import unittest +import mylib.subpackage.proto.test_pb2 as test_pb2 +import mylib.subpackage.proto.common_pb2 as common_pb2 + +print(sys.path) + +class TestProtoWithPkgPath(unittest.TestCase): + + def test_main(self): + x = test_pb2.MyMessage(name="foo", + common = common_pb2.MyCommonMessage(common="common")) + self.assertEqual(x.name, "foo") + self.assertEqual(x.common.common, "common") + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/proto_pkg_path/proto/common.proto b/python/tests/proto_pkg_path/proto/common.proto new file mode 100644 index 000000000..b24b8eaa5 --- /dev/null +++ b/python/tests/proto_pkg_path/proto/common.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +message MyCommonMessage { + string common = 1; +} diff --git a/python/tests/proto_pkg_path/proto/test.proto b/python/tests/proto_pkg_path/proto/test.proto new file mode 100644 index 000000000..55f3b17c7 --- /dev/null +++ b/python/tests/proto_pkg_path/proto/test.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +import "mylib/subpackage/proto/common.proto"; + +message MyMessage { + string name = 1; + MyCommonMessage common = 2; +} |