From b8736ae28a5fda2346ecacd8659a98b144e72b75 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 13 Dec 2021 12:51:10 -0800 Subject: [PATCH 1/6] WIP. --- bazel/workspace_defs.bzl | 6 ---- python/BUILD | 61 ++++++++++++++++++++++++++++++++++++---- python/minimal_test.py | 4 ++- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/bazel/workspace_defs.bzl b/bazel/workspace_defs.bzl index 86324dddc4..2f596f01fb 100644 --- a/bazel/workspace_defs.bzl +++ b/bazel/workspace_defs.bzl @@ -52,10 +52,6 @@ toolchain( ) """ -_build_defs_file = """ -EXT_SUFFIX = "%s" -""" - def _get_config_var(repository_ctx, name): py_program = "import sysconfig; print(sysconfig.get_config_var('%s'), end='')" result = repository_ctx.execute(["python3", "-c", py_program % (name)]) @@ -65,11 +61,9 @@ def _get_config_var(repository_ctx, name): def _python_headers_impl(repository_ctx): path = _get_config_var(repository_ctx, "INCLUDEPY") - ext_suffix = _get_config_var(repository_ctx, "EXT_SUFFIX") repository_ctx.symlink(path, "python") python3 = repository_ctx.which("python3") repository_ctx.file("BUILD.bazel", _build_file % python3) - repository_ctx.file("build_defs.bzl", _build_defs_file % ext_suffix) # The system_python() repository rule exposes Python headers from the system. # diff --git a/python/BUILD b/python/BUILD index 102e9f0bee..68cd74a790 100644 --- a/python/BUILD +++ b/python/BUILD @@ -27,10 +27,6 @@ load( "//bazel:build_defs.bzl", "UPB_DEFAULT_COPTS", ) -load( - "@system_python//:build_defs.bzl", - "EXT_SUFFIX", -) cc_binary( name = "message", @@ -74,7 +70,22 @@ cc_binary( ], ) -# Copy the extension into the location recognized by Python. +cc_binary( + name = "api_implementation", + srcs = [ + "api_implementation.c", + ], + # Enable once linker script is available. + #copts = ["-fvisibility=hidden"], + deps = ["@system_python//:python_headers"], + linkshared = True, + linkstatic = True, +) + +# Copy the extensions into the location recognized by Python. +# .abi3.so indicates use of the limited API, and cross-version ABI compatibility. +EXT_SUFFIX = ".abi3.so" + genrule( name = "message_ext", srcs = [":message"], @@ -89,3 +100,43 @@ py_test( imports = ["."], legacy_create_init = False, ) + +TESTS = [ + "descriptor_database_test", + "descriptor_pool_test", + "descriptor_test", + "generator_test", + "json_format_test", + "keywords_test", + "message_factory_test", + "message_test", + "proto_builder_test", + "reflection_test", + "service_reflection_test", + "symbol_database_test", + "text_encoding_test", + "text_format_test", + "unknown_fields_test", + "well_known_types_test", + "wire_format_test", +] + +[ + py_test( + name = test, + main = "python/google/protobuf/internal/" + test + ".py", + srcs = [ + "@com_google_protobuf//:python_tests", + ], + deps = [ + "@com_google_protobuf//:python_tests", + ], + data = [ + "@com_google_protobuf//:python_tests", + ":message_ext", + ":api_implementation_ext", + ], + imports = ["."], + legacy_create_init = False, + ) for test in TESTS +] diff --git a/python/minimal_test.py b/python/minimal_test.py index 072250a622..13f1124f30 100644 --- a/python/minimal_test.py +++ b/python/minimal_test.py @@ -50,6 +50,8 @@ class TestMessageExtension(unittest.TestCase): # system. self.assertTrue(_message._IS_UPB) +TestMessageExtension.test_descriptor_pool.__unittest_expecting_failure__ = True + if __name__ == '__main__': - unittest.main() + unittest.main(verbosity=2) From e079f1bce542905de419435119e046f002f1dde1 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 18 Dec 2021 22:10:46 -0800 Subject: [PATCH 2/6] Patched protobuf repo sufficiently for things to work. --- bazel/protobuf.patch | 10 ++++++++++ bazel/workspace_deps.bzl | 8 ++++++++ python/BUILD | 22 ++++++++++++++++++++-- python/message.c | 4 ++-- python/minimal_test.py | 5 ++++- python/protobuf.c | 3 ++- 6 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 bazel/protobuf.patch diff --git a/bazel/protobuf.patch b/bazel/protobuf.patch new file mode 100644 index 0000000000..ddf57eb69a --- /dev/null +++ b/bazel/protobuf.patch @@ -0,0 +1,10 @@ +--- BUILD ++++ BUILD +@@ -1110,6 +1110,7 @@ py_library( + ":python_common_test_protos", + ":python_specific_test_protos", + ], ++ visibility = ["//visibility:public"], + ) + + internal_protobuf_py_tests( diff --git a/bazel/workspace_deps.bzl b/bazel/workspace_deps.bzl index 0f47720c08..f825cf9c66 100644 --- a/bazel/workspace_deps.bzl +++ b/bazel/workspace_deps.bzl @@ -19,6 +19,14 @@ def upb_deps(): "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz", "https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz", ], + patches = [ + "//bazel:protobuf.patch", + ], + patch_cmds = [ + "rm python/google/protobuf/__init__.py", + "rm python/google/protobuf/pyext/__init__.py", + "rm python/google/protobuf/internal/__init__.py", + ] ) maybe( diff --git a/python/BUILD b/python/BUILD index 68cd74a790..a00b0d00ba 100644 --- a/python/BUILD +++ b/python/BUILD @@ -93,10 +93,28 @@ genrule( cmd = "cp $< $@", ) +genrule( + name = "api_implementation_ext", + srcs = [":api_implementation"], + outs = ["google/protobuf/internal/_api_implementation" + EXT_SUFFIX], + cmd = "cp $< $@", +) + py_test( name = "minimal_test", - srcs = ["minimal_test.py"], - data = [":message_ext"], + #srcs = ["minimal_test.py"], + srcs = [ + "minimal_test.py", + "@com_google_protobuf//:python_tests", + ], + deps = [ + "@com_google_protobuf//:python_tests", + ], + data = [ + "@com_google_protobuf//:python_tests", + ":message_ext", + ":api_implementation_ext", + ], imports = ["."], legacy_create_init = False, ) diff --git a/python/message.c b/python/message.c index 728b1163d2..e486fde65b 100644 --- a/python/message.c +++ b/python/message.c @@ -332,7 +332,7 @@ static bool PyUpb_CMessage_InitMapAttribute(PyObject* _self, PyObject* name, return ok >= 0; } -static bool PyUpb_CMessage_InitRepeatedAttribute() { +static bool PyUpb_CMessage_InitRepeatedAttribute(void) { // TODO(haberman): disabled until repeated container is in. // PyObject* repeated = PyUpb_CMessage_GetAttr(_self, name); // PyObject* tmp = PyUpb_RepeatedContainer_Extend(repeated, value); @@ -1537,7 +1537,7 @@ static PyType_Spec PyUpb_MessageMeta_Spec = { PyUpb_MessageMeta_Slots, }; -static PyObject* PyUpb_MessageMeta_CreateType() { +static PyObject* PyUpb_MessageMeta_CreateType(void) { PyObject* bases = Py_BuildValue("(O)", &PyType_Type); if (!bases) return NULL; PyUpb_MessageMeta_Spec.basicsize = diff --git a/python/minimal_test.py b/python/minimal_test.py index 13f1124f30..32b83338f6 100644 --- a/python/minimal_test.py +++ b/python/minimal_test.py @@ -29,6 +29,7 @@ import unittest from google.protobuf.pyext import _message +from google.protobuf.internal import api_implementation class TestMessageExtension(unittest.TestCase): @@ -48,9 +49,11 @@ class TestMessageExtension(unittest.TestCase): def test_lib_is_upb(self): # Ensure we are not pulling in a different protobuf library on the # system. + print(_message._IS_UPB) self.assertTrue(_message._IS_UPB) + self.assertEqual(api_implementation.Type(), "cpp") -TestMessageExtension.test_descriptor_pool.__unittest_expecting_failure__ = True +#TestMessageExtension.test_descriptor_pool.__unittest_expecting_failure__ = True if __name__ == '__main__': diff --git a/python/protobuf.c b/python/protobuf.c index afe92c6401..09b1552db9 100644 --- a/python/protobuf.c +++ b/python/protobuf.c @@ -288,7 +288,8 @@ PyMODINIT_FUNC PyInit__message(void) { state->obj_cache = PyUpb_WeakMap_New(); if (!PyUpb_InitDescriptorContainers(m) || !PyUpb_InitDescriptorPool(m) || - !PyUpb_InitDescriptor(m) || !PyUpb_InitArena(m)) { + !PyUpb_InitDescriptor(m) || !PyUpb_InitArena(m) || + !PyUpb_InitMessage(m)) { Py_DECREF(m); return NULL; } From 4423e917adf36f46d9cab54efe5ec6247cb1f54a Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 27 Dec 2021 18:04:58 -0800 Subject: [PATCH 3/6] All tests in the repo are passing. --- WORKSPACE | 2 + bazel/protobuf.patch | 47 +++- python/BUILD | 67 ++--- python/api_implementation.c | 50 ++++ python/descriptor.c | 5 +- python/descriptor_containers.c | 1 - python/message.c | 70 +++-- python/pb_unit_tests/BUILD | 61 +++++ python/pb_unit_tests/README.md | 11 + .../descriptor_database_test_wrapper.py | 33 +++ .../descriptor_pool_test_wrapper.py | 73 ++++++ .../pb_unit_tests/descriptor_test_wrapper.py | 85 ++++++ .../pb_unit_tests/generator_test_wrapper.py | 40 +++ .../pb_unit_tests/json_format_test_wrapper.py | 73 ++++++ python/pb_unit_tests/keywords_test_wrapper.py | 35 +++ .../message_factory_test_wrapper.py | 41 +++ python/pb_unit_tests/message_test_wrapper.py | 204 +++++++++++++++ .../proto_builder_test_wrapper.py | 35 +++ .../pb_unit_tests/reflection_test_wrapper.py | 172 ++++++++++++ .../service_reflection_test_wrapper.py | 30 +++ .../symbol_database_test_wrapper.py | 39 +++ .../text_encoding_test_wrapper.py | 30 +++ .../pb_unit_tests/text_format_test_wrapper.py | 247 ++++++++++++++++++ .../unknown_fields_test_wrapper.py | 58 ++++ .../well_known_types_test_wrapper.py | 51 ++++ .../pb_unit_tests/wire_format_test_wrapper.py | 30 +++ python/protobuf.c | 9 +- 27 files changed, 1519 insertions(+), 80 deletions(-) create mode 100644 python/api_implementation.c create mode 100644 python/pb_unit_tests/BUILD create mode 100644 python/pb_unit_tests/README.md create mode 100644 python/pb_unit_tests/descriptor_database_test_wrapper.py create mode 100644 python/pb_unit_tests/descriptor_pool_test_wrapper.py create mode 100644 python/pb_unit_tests/descriptor_test_wrapper.py create mode 100644 python/pb_unit_tests/generator_test_wrapper.py create mode 100644 python/pb_unit_tests/json_format_test_wrapper.py create mode 100644 python/pb_unit_tests/keywords_test_wrapper.py create mode 100644 python/pb_unit_tests/message_factory_test_wrapper.py create mode 100644 python/pb_unit_tests/message_test_wrapper.py create mode 100644 python/pb_unit_tests/proto_builder_test_wrapper.py create mode 100644 python/pb_unit_tests/reflection_test_wrapper.py create mode 100644 python/pb_unit_tests/service_reflection_test_wrapper.py create mode 100644 python/pb_unit_tests/symbol_database_test_wrapper.py create mode 100644 python/pb_unit_tests/text_encoding_test_wrapper.py create mode 100644 python/pb_unit_tests/text_format_test_wrapper.py create mode 100644 python/pb_unit_tests/unknown_fields_test_wrapper.py create mode 100644 python/pb_unit_tests/well_known_types_test_wrapper.py create mode 100644 python/pb_unit_tests/wire_format_test_wrapper.py diff --git a/WORKSPACE b/WORKSPACE index 1b4e1cbe1a..fd90b56289 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -43,6 +43,8 @@ system_python( name = "system_python" ) +register_toolchains("@system_python//:python_toolchain") + http_archive( name = "rules_fuzzing", sha256 = "e1b54211f7cee604194db080a8765220d3ef5db2a873fded429ce13e74d93a6b", diff --git a/bazel/protobuf.patch b/bazel/protobuf.patch index ddf57eb69a..ffe5debd62 100644 --- a/bazel/protobuf.patch +++ b/bazel/protobuf.patch @@ -1,10 +1,47 @@ --- BUILD +++ BUILD -@@ -1110,6 +1110,7 @@ py_library( - ":python_common_test_protos", - ":python_specific_test_protos", - ], +@@ -931,13 +931,10 @@ py_library( + [ + "python/google/protobuf/**/*.py", + ], +- exclude = [ +- "python/google/protobuf/internal/*_test.py", +- "python/google/protobuf/internal/test_util.py", +- ], + ), + imports = ["python"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], ) - internal_protobuf_py_tests( + cc_binary( +@@ -1038,13 +1035,6 @@ py_proto_library( + name = "protobuf_python", + srcs = COPIED_WELL_KNOWN_PROTOS, + include = "python", +- data = select({ +- "//conditions:default": [], +- ":use_fast_cpp_protos": [ +- ":python/google/protobuf/internal/_api_implementation.so", +- ":python/google/protobuf/pyext/_message.so", +- ], +- }), + default_runtime = "", + protoc = ":protoc", + py_libs = [ +@@ -1080,6 +1070,7 @@ py_proto_library( + protoc = ":protoc", + srcs_version = "PY2AND3", + deps = [":protobuf_python"], ++ visibility = ["//visibility:public"], + ) + + py_proto_library( +@@ -1093,6 +1084,7 @@ py_proto_library( + protoc = ":protoc", + srcs_version = "PY2AND3", + deps = [":python_common_test_protos"], ++ visibility = ["//visibility:public"], + ) + + py_library( diff --git a/python/BUILD b/python/BUILD index a00b0d00ba..474a25426e 100644 --- a/python/BUILD +++ b/python/BUILD @@ -87,74 +87,41 @@ cc_binary( EXT_SUFFIX = ".abi3.so" genrule( - name = "message_ext", + name = "copy_message", srcs = [":message"], outs = ["google/protobuf/pyext/_message" + EXT_SUFFIX], cmd = "cp $< $@", ) genrule( - name = "api_implementation_ext", + name = "copy_api_implementation", srcs = [":api_implementation"], outs = ["google/protobuf/internal/_api_implementation" + EXT_SUFFIX], cmd = "cp $< $@", + visibility = ["//python:__subpackages__"], +) + +py_library( + name = "message_ext", + data = [ + "google/protobuf/pyext/_message" + EXT_SUFFIX, + "google/protobuf/internal/_api_implementation" + EXT_SUFFIX, + ], + imports = ["."], + visibility = ["//python:__subpackages__"], ) py_test( name = "minimal_test", - #srcs = ["minimal_test.py"], srcs = [ "minimal_test.py", - "@com_google_protobuf//:python_tests", ], deps = [ - "@com_google_protobuf//:python_tests", - ], - data = [ - "@com_google_protobuf//:python_tests", - ":message_ext", - ":api_implementation_ext", + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", ], imports = ["."], legacy_create_init = False, ) - -TESTS = [ - "descriptor_database_test", - "descriptor_pool_test", - "descriptor_test", - "generator_test", - "json_format_test", - "keywords_test", - "message_factory_test", - "message_test", - "proto_builder_test", - "reflection_test", - "service_reflection_test", - "symbol_database_test", - "text_encoding_test", - "text_format_test", - "unknown_fields_test", - "well_known_types_test", - "wire_format_test", -] - -[ - py_test( - name = test, - main = "python/google/protobuf/internal/" + test + ".py", - srcs = [ - "@com_google_protobuf//:python_tests", - ], - deps = [ - "@com_google_protobuf//:python_tests", - ], - data = [ - "@com_google_protobuf//:python_tests", - ":message_ext", - ":api_implementation_ext", - ], - imports = ["."], - legacy_create_init = False, - ) for test in TESTS -] diff --git a/python/api_implementation.c b/python/api_implementation.c new file mode 100644 index 0000000000..9f96b936d3 --- /dev/null +++ b/python/api_implementation.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009-2021, Google LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Google LLC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +static struct PyModuleDef module_def = { + PyModuleDef_HEAD_INIT, + "google.protobuf.internal._api_implementation", + "Protobuf Module", + -1, + NULL, + NULL, + NULL, + NULL, + NULL}; + +PyMODINIT_FUNC PyInit__api_implementation(void) { + PyObject* module = PyModule_Create(&module_def); + + if (PyModule_AddIntConstant(module, "api_version", 2)) { + Py_DECREF(module); + return NULL; + } + + return module; +} diff --git a/python/descriptor.c b/python/descriptor.c index cd8f6994a0..3877e55a5b 100644 --- a/python/descriptor.c +++ b/python/descriptor.c @@ -190,6 +190,7 @@ static void PyUpb_DescriptorBase_Dealloc(PyUpb_DescriptorBase* base) { // ----------------------------------------------------------------------------- PyObject* PyUpb_Descriptor_Get(const upb_msgdef* m) { + assert(m); const upb_filedef* file = upb_msgdef_file(m); return PyUpb_DescriptorBase_Get(kPyUpb_Descriptor, m, file); } @@ -647,7 +648,9 @@ static PyObject* PyUpb_EnumDescriptor_GetValuesByNumber(PyObject* _self, static PyObject* PyUpb_EnumDescriptor_GetContainingType(PyObject* _self, void* closure) { PyUpb_DescriptorBase* self = (void*)_self; - return PyUpb_Descriptor_Get(upb_enumdef_containingtype(self->def)); + const upb_msgdef* m = upb_enumdef_containingtype(self->def); + if (!m) Py_RETURN_NONE; + return PyUpb_Descriptor_Get(m); } static PyObject* PyUpb_EnumDescriptor_GetHasOptions(PyObject* _self, diff --git a/python/descriptor_containers.c b/python/descriptor_containers.c index 1de94edcf1..22b201dbe2 100644 --- a/python/descriptor_containers.c +++ b/python/descriptor_containers.c @@ -174,7 +174,6 @@ static int PyUpb_GenericSequence_IsEqual(PyUpb_GenericSequence *self, if (!item1 || !item2) goto error; int cmp = PyObject_RichCompareBool(item1, item2, Py_EQ); Py_DECREF(item1); - Py_DECREF(item2); if (cmp != 1) return cmp; } // All items were found and equal diff --git a/python/message.c b/python/message.c index e486fde65b..3d247bbfbd 100644 --- a/python/message.c +++ b/python/message.c @@ -326,10 +326,13 @@ void PyUpb_CMessage_AssureWritable(PyUpb_CMessage* self); static bool PyUpb_CMessage_InitMapAttribute(PyObject* _self, PyObject* name, const upb_fielddef* f, PyObject* value) { - PyObject* map = PyUpb_CMessage_GetAttr(_self, name); - int ok = PyUpb_CMessage_InitMapAttributes(map, value, f); - Py_DECREF(map); - return ok >= 0; + // TODO(haberman): disabled until map container is in. + // PyObject* map = PyUpb_CMessage_GetAttr(_self, name); + // int ok = PyUpb_CMessage_InitMapAttributes(map, value, f); + // Py_DECREF(map); + // return ok >= 0; + PyErr_SetString(PyExc_NotImplementedError, "map init"); + return false; } static bool PyUpb_CMessage_InitRepeatedAttribute(void) { @@ -909,23 +912,37 @@ static PyObject* PyUpb_CMessage_HasField(PyObject* _self, PyObject* arg) { static PyObject* PyUpb_CMessage_ListFields(PyObject* _self, PyObject* arg) { PyObject* list = PyList_New(0); upb_msg* msg = PyUpb_CMessage_GetIfWritable(_self); + if (!msg) return list; - if (msg) { - size_t iter1 = UPB_MSG_BEGIN; - const upb_msgdef* m = PyUpb_CMessage_GetMsgdef(_self); - const upb_symtab* symtab = upb_filedef_symtab(upb_msgdef_file(m)); - const upb_fielddef* f; - upb_msgval val; - while (upb_msg_next(msg, m, symtab, &f, &val, &iter1)) { - PyObject* field_desc = PyUpb_FieldDescriptor_Get(f); - PyObject* py_val = PyUpb_CMessage_GetFieldValue(_self, f); - PyObject* tuple = Py_BuildValue("(NN)", field_desc, py_val); - PyList_Append(list, tuple); - Py_DECREF(tuple); - } + size_t iter1 = UPB_MSG_BEGIN; + const upb_msgdef* m = PyUpb_CMessage_GetMsgdef(_self); + const upb_symtab* symtab = upb_filedef_symtab(upb_msgdef_file(m)); + const upb_fielddef* f; + PyObject* field_desc = NULL; + PyObject* py_val = NULL; + PyObject* tuple = NULL; + upb_msgval val; + while (upb_msg_next(msg, m, symtab, &f, &val, &iter1)) { + PyObject* field_desc = PyUpb_FieldDescriptor_Get(f); + PyObject* py_val = PyUpb_CMessage_GetFieldValue(_self, f); + if (!field_desc || !py_val) goto err; + PyObject* tuple = Py_BuildValue("(NN)", field_desc, py_val); + field_desc = NULL; + py_val = NULL; + if (!tuple) goto err; + if (!PyList_Append(list, tuple)) goto err; + Py_DECREF(tuple); + tuple = NULL; } return list; + +err: + Py_XDECREF(field_desc); + Py_XDECREF(py_val); + Py_XDECREF(tuple); + Py_DECREF(list); + return NULL; } PyObject* PyUpb_CMessage_MergeFrom(PyObject* self, PyObject* arg) { @@ -1438,8 +1455,9 @@ static PyObject* PyUpb_MessageMeta_New(PyTypeObject* type, PyObject* args, Py_ssize_t size = PyTuple_Size(bases); if (!(size == 0 || (size == 1 && PyTuple_GetItem(bases, 0) == state->message_class))) { - PyErr_SetString(PyExc_TypeError, - "A Message class can only inherit from Message"); + PyErr_Format(PyExc_TypeError, + "A Message class can only inherit from Message, not %S", + bases); return NULL; } @@ -1558,5 +1576,19 @@ bool PyUpb_InitMessage(PyObject* m) { if (!state->cmessage_type || !state->message_meta_type) return false; if (PyModule_AddObject(m, "MessageMeta", message_meta_type)) return false; + PyObject* mod = PyImport_ImportModule("google.protobuf.message"); + + if (mod == NULL) return false; + + state->encode_error_class = PyObject_GetAttrString(mod, "EncodeError"); + state->decode_error_class = PyObject_GetAttrString(mod, "DecodeError"); + state->message_class = PyObject_GetAttrString(mod, "Message"); + Py_DECREF(mod); + + if (!state->encode_error_class || !state->decode_error_class || + !state->message_class) { + return false; + } + return true; } diff --git a/python/pb_unit_tests/BUILD b/python/pb_unit_tests/BUILD new file mode 100644 index 0000000000..4a32c4ba10 --- /dev/null +++ b/python/pb_unit_tests/BUILD @@ -0,0 +1,61 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +TESTS = [ + "descriptor_database_test", + "descriptor_pool_test", + "descriptor_test", + "generator_test", + "json_format_test", + "keywords_test", + "message_factory_test", + "message_test", + "proto_builder_test", + "reflection_test", + "service_reflection_test", + "symbol_database_test", + "text_encoding_test", + "text_format_test", + "unknown_fields_test", + "well_known_types_test", + "wire_format_test", +] + +[ + py_test( + name = test, + main = test + "_wrapper.py", + srcs = [ + test + "_wrapper.py", + ], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, + ) for test in TESTS +] diff --git a/python/pb_unit_tests/README.md b/python/pb_unit_tests/README.md new file mode 100644 index 0000000000..669f0674da --- /dev/null +++ b/python/pb_unit_tests/README.md @@ -0,0 +1,11 @@ + +# Protobuf Unit Tests + +This directory contains wrappers around the Python unit tests defined in +the protobuf repo. Python+upb is intended to be a drop-in replacement for +protobuf Python, so we should be able to pass the same set of unit tests. + +Our wrappers contain exclusion lists for tests we know we are not currently +passing. Ideally these exclusion lists will become empty once Python+upb is +fully implemented. However there may be a few edge cases that we decide +are not worth matching with perfect parity. diff --git a/python/pb_unit_tests/descriptor_database_test_wrapper.py b/python/pb_unit_tests/descriptor_database_test_wrapper.py new file mode 100644 index 0000000000..69fe7de269 --- /dev/null +++ b/python/pb_unit_tests/descriptor_database_test_wrapper.py @@ -0,0 +1,33 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import descriptor_database_test +import unittest + +descriptor_database_test.DescriptorDatabaseTest.testAdd.__unittest_expecting_failure__ = True +descriptor_database_test.DescriptorDatabaseTest.testConflictRegister.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=descriptor_database_test, verbosity=2) diff --git a/python/pb_unit_tests/descriptor_pool_test_wrapper.py b/python/pb_unit_tests/descriptor_pool_test_wrapper.py new file mode 100644 index 0000000000..74081e0c9d --- /dev/null +++ b/python/pb_unit_tests/descriptor_pool_test_wrapper.py @@ -0,0 +1,73 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import descriptor_pool_test +import unittest + +print(unittest) + +descriptor_pool_test.AddDescriptorTest.testAddTypeError.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testCustomDescriptorPool.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testEmptyDescriptorPool.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testEnum.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testFile.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testFileDescriptorOptionsWithCustomDescriptorPool.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testMessage.__unittest_expecting_failure__ = True +descriptor_pool_test.AddDescriptorTest.testService.__unittest_expecting_failure__ = True + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUp(): +# +# AttributeError: 'google.protobuf.pyext._message.FileDescriptor' object has no attribute 'serialized_pb' +# +# TODO: change to __unittest_expecting_failure__ when serialized_pb is available. +descriptor_pool_test.CreateDescriptorPoolTest.testAddSerializedFile.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testComplexNesting.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testConflictRegister.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testDefaultValueForCustomMessages.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testEnumDefaultValue.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testExtensionsAreNotFields.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindAllExtensions.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindEnumTypeByName.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindEnumTypeByNameFailure.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindExtensionByName.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindExtensionByNumber.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindFieldByName.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindFileByName.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindFileByNameFailure.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindFileContainingSymbol.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindFileContainingSymbolFailure.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindMessageTypeByName.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindMessageTypeByNameFailure.__unittest_skip__ = True +descriptor_pool_test.DefaultDescriptorPoolTest.testFindMethods.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindOneofByName.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindService.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testFindTypeErrors.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testUserDefinedDB.__unittest_skip__ = True +descriptor_pool_test.CreateDescriptorPoolTest.testAddFileDescriptor.__unittest_skip__ = True +descriptor_pool_test.SecondaryDescriptorFromDescriptorDB.testErrorCollector.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=descriptor_pool_test, verbosity=2) diff --git a/python/pb_unit_tests/descriptor_test_wrapper.py b/python/pb_unit_tests/descriptor_test_wrapper.py new file mode 100644 index 0000000000..06696cd247 --- /dev/null +++ b/python/pb_unit_tests/descriptor_test_wrapper.py @@ -0,0 +1,85 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import descriptor_test +import unittest + +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_AllExtensions.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_EmptyMessage.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_FileDescriptor.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_ForeignEnum.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_ForeignNestedMessage.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_MethodDescriptor.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_NestedMessage.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_Options.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_ServiceDescriptor.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_SeveralExtensions.__unittest_expecting_failure__ = True +descriptor_test.DescriptorCopyToProtoTest.testCopyToProto_TypeError.__unittest_expecting_failure__ = True +descriptor_test.GeneratedDescriptorTest.testDescriptor.__unittest_expecting_failure__ = True +descriptor_test.MakeDescriptorTest.testCamelcaseName.__unittest_expecting_failure__ = True +descriptor_test.MakeDescriptorTest.testJsonName.__unittest_expecting_failure__ = True +descriptor_test.MakeDescriptorTest.testMakeDescriptorWithNestedFields.__unittest_expecting_failure__ = True +descriptor_test.MakeDescriptorTest.testMakeDescriptorWithOptions.__unittest_expecting_failure__ = True +descriptor_test.MakeDescriptorTest.testMakeDescriptorWithUnsignedIntField.__unittest_expecting_failure__ = True + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUp(): +# +# NotImplementedError: unset repeated +# +# TODO: change to __unittest_expecting_failure__ when repeated fields are checked in. +descriptor_test.DescriptorTest.testAggregateOptions.__unittest_skip__ = True +descriptor_test.DescriptorTest.testComplexExtensionOptions.__unittest_skip__ = True +descriptor_test.DescriptorTest.testContainingServiceFixups.__unittest_skip__ = True +descriptor_test.DescriptorTest.testContainingTypeFixups.__unittest_skip__ = True +descriptor_test.DescriptorTest.testCustomOptionsCopyTo.__unittest_skip__ = True +descriptor_test.DescriptorTest.testDefault.__unittest_skip__ = True +descriptor_test.DescriptorTest.testDifferentCustomOptionTypes.__unittest_skip__ = True +descriptor_test.DescriptorTest.testEnumFixups.__unittest_skip__ = True +descriptor_test.DescriptorTest.testEnumValueName.__unittest_skip__ = True +descriptor_test.DescriptorTest.testFileDescriptor.__unittest_skip__ = True +descriptor_test.DescriptorTest.testFileDescriptorReferences.__unittest_skip__ = True +descriptor_test.DescriptorTest.testGetOptions.__unittest_skip__ = True +descriptor_test.DescriptorTest.testImmutableCppDescriptor.__unittest_skip__ = True +descriptor_test.DescriptorTest.testNestedOptions.__unittest_skip__ = True +descriptor_test.DescriptorTest.testSimpleCustomOptions.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testAggregateOptions.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testComplexExtensionOptions.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testContainingServiceFixups.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testContainingTypeFixups.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testCustomOptionsCopyTo.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testDefault.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testDifferentCustomOptionTypes.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testEnumFixups.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testEnumValueName.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testFileDescriptor.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testFileDescriptorReferences.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testGetOptions.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testImmutableCppDescriptor.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testNestedOptions.__unittest_skip__ = True +descriptor_test.NewDescriptorTest.testSimpleCustomOptions.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=descriptor_test, verbosity=2) diff --git a/python/pb_unit_tests/generator_test_wrapper.py b/python/pb_unit_tests/generator_test_wrapper.py new file mode 100644 index 0000000000..daa8f95b03 --- /dev/null +++ b/python/pb_unit_tests/generator_test_wrapper.py @@ -0,0 +1,40 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import generator_test +import unittest + +generator_test.GeneratorTest.testBadIdentifiers.__unittest_expecting_failure__ = True +generator_test.GeneratorTest.testExtensionScope.__unittest_expecting_failure__ = True +generator_test.GeneratorTest.testFileDescriptor.__unittest_expecting_failure__ = True +generator_test.GeneratorTest.testMessageWithCustomOptions.__unittest_expecting_failure__ = True +generator_test.GeneratorTest.testOneof.__unittest_expecting_failure__ = True +generator_test.GeneratorTest.testOptions.__unittest_expecting_failure__ = True +generator_test.SymbolDatabaseRegistrationTest.testEnums.__unittest_expecting_failure__ = True +generator_test.SymbolDatabaseRegistrationTest.testFindFileByName.__unittest_expecting_failure__ = True +generator_test.SymbolDatabaseRegistrationTest.testGetSymbol.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=generator_test, verbosity=2) diff --git a/python/pb_unit_tests/json_format_test_wrapper.py b/python/pb_unit_tests/json_format_test_wrapper.py new file mode 100644 index 0000000000..cb523efcf8 --- /dev/null +++ b/python/pb_unit_tests/json_format_test_wrapper.py @@ -0,0 +1,73 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import json_format_test +import unittest + +json_format_test.JsonFormatTest.testAllFieldsToJson.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testAlwaysSeriliaze.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testAnyMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testAnyMessageDescriptorPoolMissingType.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testDurationMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testEmptyMessageToJson.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testExtensionSerializationDictMatchesProto3Spec.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testExtensionSerializationDictMatchesProto3SpecMore.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testExtensionSerializationJsonMatchesProto3Spec.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testExtensionToDictAndBack.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testExtensionToDictAndBackWithScalar.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testExtensionToJsonAndBack.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testFieldMaskMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testFloatPrecision.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testFormatEnumsAsInts.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testIgnoreUnknownField.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testIndent.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testInvalidAny.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testInvalidMap.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testInvalidTimestamp.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testJsonEscapeString.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testJsonName.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testJsonParseDictToAnyDoesNotAlterInput.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testListValueMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testMapFields.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testMessageToDict.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testNanFloat.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testNullValue.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testOneofFields.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testParseDictAnyDescriptorPoolMissingType.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testParseDoubleToFloat.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testParseNull.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testPartialMessageToJson.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testPreservingProtoFieldNames.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testProto3Optional.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testSortKeys.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testStructMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testTimestampMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testUnknownEnumToJsonAndBack.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testValueMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testWellKnownInAnyMessage.__unittest_expecting_failure__ = True +json_format_test.JsonFormatTest.testWrapperMessage.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=json_format_test, verbosity=2) diff --git a/python/pb_unit_tests/keywords_test_wrapper.py b/python/pb_unit_tests/keywords_test_wrapper.py new file mode 100644 index 0000000000..b10d72ac4d --- /dev/null +++ b/python/pb_unit_tests/keywords_test_wrapper.py @@ -0,0 +1,35 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import keywords_test +import unittest + +keywords_test.KeywordsConflictTest.testExtension.__unittest_expecting_failure__ = True +keywords_test.KeywordsConflictTest.testExtensionForNestedMessage.__unittest_expecting_failure__ = True +keywords_test.KeywordsConflictTest.testMessage.__unittest_expecting_failure__ = True +keywords_test.KeywordsConflictTest.testNestedMessage.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=keywords_test, verbosity=2) diff --git a/python/pb_unit_tests/message_factory_test_wrapper.py b/python/pb_unit_tests/message_factory_test_wrapper.py new file mode 100644 index 0000000000..9b009b660b --- /dev/null +++ b/python/pb_unit_tests/message_factory_test_wrapper.py @@ -0,0 +1,41 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import message_factory_test +import unittest + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUp(): +# +# AttributeError: 'google.protobuf.pyext._message.FileDescriptor' object has no attribute 'serialized_pb' +# +# TODO: change to __unittest_expecting_failure__ when serialized_pb is available. +message_factory_test.MessageFactoryTest.testCreatePrototypeOverride.__unittest_skip__ = True +message_factory_test.MessageFactoryTest.testDuplicateExtensionNumber.__unittest_skip__ = True +message_factory_test.MessageFactoryTest.testGetMessages.__unittest_skip__ = True +message_factory_test.MessageFactoryTest.testGetPrototype.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=message_factory_test, verbosity=2) diff --git a/python/pb_unit_tests/message_test_wrapper.py b/python/pb_unit_tests/message_test_wrapper.py new file mode 100644 index 0000000000..dc1a2111b2 --- /dev/null +++ b/python/pb_unit_tests/message_test_wrapper.py @@ -0,0 +1,204 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import message_test +import unittest + +message_test.MessageTest.testAddWrongRepeatedNestedField_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testAddWrongRepeatedNestedField_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testAppendRepeatedCompositeField_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testAppendRepeatedCompositeField_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testBadUtf8String_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testBadUtf8String_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testDeterminismParameters_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testDeterminismParameters_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendFloatWithIterable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendFloatWithIterable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendFloatWithNothing_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendFloatWithNothing_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendFloatWithPythonList_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendFloatWithPythonList_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendInt32WithIterable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendInt32WithIterable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendInt32WithNothing_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendInt32WithNothing_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendInt32WithPythonList_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendInt32WithPythonList_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendShouldNotSwallowExceptions_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendShouldNotSwallowExceptions_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithIterable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithIterable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithNothing_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithNothing_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithPythonList_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithPythonList_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithString_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testExtendStringWithString_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testFloatPrinting_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testFloatPrinting_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testGoldenMessage_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testGoldenMessage_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testGoldenPackedMessage_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testGoldenPackedMessage_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testHighPrecisionDoublePrinting_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testHighPrecisionDoublePrinting_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testInsertRepeatedCompositeField_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testInsertRepeatedCompositeField_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testLongValuedSlice_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testLongValuedSlice_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFromRepeatedField_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFromRepeatedField_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFromStringUsingMemoryView_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFromStringUsingMemoryView_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFromString_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFromString_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFrom_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testMergeFrom_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testNegativeInfinityPacked_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testNegativeInfinityPacked_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testNegativeInfinity_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testNegativeInfinity_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testNotANumberPacked_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testNotANumberPacked_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testNotANumber_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testNotANumber_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testOneofMessageMergeFrom_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testOneofMessageMergeFrom_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testOneofNestedMergeFrom_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testOneofNestedMergeFrom_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testPickleNestedMessage_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testPickleNestedMessage_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testPickleNestedNestedMessage_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testPickleNestedNestedMessage_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testPickleSupport_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testPickleSupport_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testPositiveInfinityPacked_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testPositiveInfinityPacked_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testPositiveInfinity_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testPositiveInfinity_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testReleasedNestedMessages_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testReleasedNestedMessages_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedCompareWithSelf_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedCompareWithSelf_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedCompositeFieldPop_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedCompositeFieldPop_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedCompositeFieldSortArguments_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedCompositeFieldSortArguments_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedContains_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedContains_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldInsideNestedMessage_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldInsideNestedMessage_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldsAreSequences_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldsAreSequences_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldsComparable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldsComparable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldsNotHashable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedFieldsNotHashable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedNestedFieldIteration_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedNestedFieldIteration_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedScalarFieldPop_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedScalarFieldPop_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedScalarFieldSortArguments_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedScalarFieldSortArguments_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedScalarIterable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testRepeatedScalarIterable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testReturningType_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testReturningType_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testSetRepeatedComposite_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testSetRepeatedComposite_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortEmptyRepeatedCompositeContainer_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortEmptyRepeatedCompositeContainer_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedCompositeFieldsCustomComparator_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedCompositeFieldsCustomComparator_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedCompositeFieldsStable_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedCompositeFieldsStable_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedScalarFieldsCustomComparator_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedScalarFieldsCustomComparator_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedScalarFieldsDefaultComparator_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testSortingRepeatedScalarFieldsDefaultComparator_proto3.__unittest_expecting_failure__ = True +message_test.MessageTest.testUnknownFieldPrinting_proto2.__unittest_expecting_failure__ = True +message_test.MessageTest.testUnknownFieldPrinting_proto3.__unittest_expecting_failure__ = True +message_test.PackedFieldTest.testPackedFields.__unittest_expecting_failure__ = True +message_test.PackedFieldTest.testUnpackedFields.__unittest_expecting_failure__ = True +message_test.Proto2Test.testAssignInvalidEnum.__unittest_expecting_failure__ = True +message_test.Proto2Test.testExtensionsErrors.__unittest_expecting_failure__ = True +message_test.Proto2Test.testFieldPresence.__unittest_expecting_failure__ = True +message_test.Proto2Test.testGoldenExtensions.__unittest_expecting_failure__ = True +message_test.Proto2Test.testGoldenPackedExtensions.__unittest_expecting_failure__ = True +message_test.Proto2Test.testMergeFromExtensions.__unittest_expecting_failure__ = True +message_test.Proto2Test.testParsingMerge.__unittest_expecting_failure__ = True +message_test.Proto2Test.testPickleIncompleteProto.__unittest_expecting_failure__ = True +message_test.Proto2Test.testPythonicInit.__unittest_expecting_failure__ = True +message_test.Proto2Test.testUnknownEnumMap.__unittest_expecting_failure__ = True +message_test.Proto2Test.test_documentation.__unittest_expecting_failure__ = True +message_test.Proto3Test.testAssignUnknownEnum.__unittest_expecting_failure__ = True +message_test.Proto3Test.testCopyFromBadType.__unittest_expecting_failure__ = True +message_test.Proto3Test.testFieldPresence.__unittest_expecting_failure__ = True +message_test.Proto3Test.testIntegerMapWithLongs.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapAssignmentCausesPresence.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapAssignmentCausesPresenceForSubmessages.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapByteSize.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapConstruction.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapDelete.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapDeterministicSerialization.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapEntryAlwaysSerialized.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapFieldRaisesCorrectError.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapFindInitializationErrorsSmokeTest.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapGet.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapItems.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapIterInvalidatedByClearField.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapIteration.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapIterationClearMessage.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapMergeFrom.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapMessageFieldConstruction.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapScalarFieldConstruction.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapValidAfterFieldCleared.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapsAreMapping.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMapsCompare.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMergeFrom.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMergeFromBadType.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMessageMap.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMessageMapItemValidAfterTopMessageCleared.__unittest_expecting_failure__ = True +message_test.Proto3Test.testMessageMapValidAfterFieldCleared.__unittest_expecting_failure__ = True +message_test.Proto3Test.testModifyMapWhileIterating.__unittest_expecting_failure__ = True +message_test.Proto3Test.testNestedMessageMapItemDelete.__unittest_expecting_failure__ = True +message_test.Proto3Test.testProto3Optional.__unittest_expecting_failure__ = True +message_test.Proto3Test.testProto3ParserDropDefaultScalar.__unittest_expecting_failure__ = True +message_test.Proto3Test.testScalarMap.__unittest_expecting_failure__ = True +message_test.Proto3Test.testScalarMapDefaults.__unittest_expecting_failure__ = True +message_test.Proto3Test.testStringUnicodeConversionInMap.__unittest_expecting_failure__ = True +message_test.Proto3Test.testSubmessageMap.__unittest_expecting_failure__ = True +message_test.ValidTypeNamesTest.testTypeNamesCanBeImported.__unittest_expecting_failure__ = True + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUpClass(): +# +# NotImplementedError: unset repeated +# +# TODO: change to __unittest_expecting_failure__ when repeated fields are available +message_test.OversizeProtosTest.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=message_test, verbosity=2) diff --git a/python/pb_unit_tests/proto_builder_test_wrapper.py b/python/pb_unit_tests/proto_builder_test_wrapper.py new file mode 100644 index 0000000000..2da28f34f2 --- /dev/null +++ b/python/pb_unit_tests/proto_builder_test_wrapper.py @@ -0,0 +1,35 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import proto_builder_test +import unittest + +proto_builder_test.ProtoBuilderTest.testMakeLargeProtoClass.__unittest_expecting_failure__ = True +proto_builder_test.ProtoBuilderTest.testMakeSameProtoClassTwice.__unittest_expecting_failure__ = True +proto_builder_test.ProtoBuilderTest.testMakeSimpleProtoClass.__unittest_expecting_failure__ = True +proto_builder_test.ProtoBuilderTest.testOrderedFields.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=proto_builder_test, verbosity=2) diff --git a/python/pb_unit_tests/reflection_test_wrapper.py b/python/pb_unit_tests/reflection_test_wrapper.py new file mode 100644 index 0000000000..62e21fc03b --- /dev/null +++ b/python/pb_unit_tests/reflection_test_wrapper.py @@ -0,0 +1,172 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import reflection_test +import unittest + +reflection_test.ByteSizeTest.testCacheInvalidationForNonrepeatedMessage.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testCacheInvalidationForNonrepeatedScalar.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testCacheInvalidationForRepeatedMessage.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testCacheInvalidationForRepeatedScalar.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testExtensions.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testPackedExtensions.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testPackedRepeatedScalars.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testRepeatedComposites.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testRepeatedCompositesDelete.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testRepeatedGroups.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testRepeatedScalars.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testRepeatedScalarsExtend.__unittest_expecting_failure__ = True +reflection_test.ByteSizeTest.testRepeatedScalarsRemove.__unittest_expecting_failure__ = True +reflection_test.ClassAPITest.testMakeClassWithNestedDescriptor.__unittest_expecting_failure__ = True +reflection_test.ClassAPITest.testParsingFlatClass.__unittest_expecting_failure__ = True +reflection_test.ClassAPITest.testParsingNestedClass.__unittest_expecting_failure__ = True +reflection_test.ExtensionEqualityTest.testExtensionEquality.__unittest_expecting_failure__ = True +reflection_test.MutualRecursionEqualityTest.testEqualityWithMutualRecursion.__unittest_expecting_failure__ = True +reflection_test.OptionsTest.testMessageOptions.__unittest_expecting_failure__ = True +reflection_test.OptionsTest.testPackedOptions.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testClear.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testClearRemovesChildren.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testDisconnectingInOneof.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testDisconnectionAfterClearingEmptyMessage.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testExtensionContainsError.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testExtensionDelete.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testExtensionFailureModes.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testExtensionIter.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testFileDescriptorErrors.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testHasBitsForAncestorsOfExtendedMessage.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testHasBitsForManyLevelsOfNesting.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testHasBitsWhenModifyingRepeatedFields.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testIsInitialized.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testListFieldsAndExtensions.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testMergeFromExtensionsNestedMessage.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testMergeFromExtensionsRepeated.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testMergeFromExtensionsSingular.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testMergeFromOptionalGroup.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testNestedExtensions.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRegisteredExtensions.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedCompositeConstructor.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedCompositeRemove.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedCompositeReverse_Empty.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedCompositeReverse_NonEmpty.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedComposites.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedListExtensions.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedScalars.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedScalarsRemove.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedScalarsReverse_Empty.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testRepeatedScalarsReverse_NonEmpty.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testSingularListExtensions.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testStringUTF8Serialization.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForOptionalMessage.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForOptionalScalar.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForRepeatedMessage.__unittest_expecting_failure__ = True +reflection_test.Proto2ReflectionTest.testTopLevelExtensionsForRepeatedScalar.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testClearFieldWithUnknownFieldName_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testClearFieldWithUnknownFieldName_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testConstructorInvalidatesCachedByteSize_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testConstructorInvalidatesCachedByteSize_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testConstructorTypeError_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testConstructorTypeError_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testCopyFromAllFields_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testCopyFromAllFields_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testCopyFromRepeatedField_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testCopyFromRepeatedField_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testCopyFromSelf_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testCopyFromSelf_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testDeepCopy_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testDeepCopy_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testDisallowedAssignments_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testDisallowedAssignments_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testDisconnectingBeforeClear_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testDisconnectingBeforeClear_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testEnum_KeysAndValues_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testEnum_KeysAndValues_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testEnum_Name_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testEnum_Name_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testEnum_Value_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testEnum_Value_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testIllegalValuesForIntegers_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testIllegalValuesForIntegers_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMergeFromAllFields_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMergeFromAllFields_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMergeFromRepeatedField_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMergeFromRepeatedField_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMergeFromRepeatedNestedMessage_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMergeFromRepeatedNestedMessage_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMixedConstructor_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testMixedConstructor_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testOneOf_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testOneOf_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testRepeatedListFields_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testRepeatedListFields_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testRepeatedScalarConstructor_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testRepeatedScalarConstructor_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testRepeatedScalarTypeSafety_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testRepeatedScalarTypeSafety_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testSingleScalarTypeSafety_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testSingleScalarTypeSafety_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testSingularListFields_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testSingularListFields_proto3.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testStaticParseFrom_proto2.__unittest_expecting_failure__ = True +reflection_test.ReflectionTest.testStaticParseFrom_proto3.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testCanonicalSerializationOrder.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testCanonicalSerializationOrderSameAsCpp.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testExtensionFieldNumbers.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testFieldDataDescriptor.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testFieldNumbers.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testFieldProperties.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testInitArgsUnknownFieldName.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testInitKwargs.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testInitRepeatedKwargs.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testInitRequiredForeignKwargs.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testInitRequiredKwargs.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testMergeFromStringWhenFieldsAlreadySet.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testMergePackedFromStringWhenSomeFieldsAlreadySet.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testMessageSetWireFormat.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testMessageSetWireFormatUnknownExtension.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testPackedFieldsWireFormat.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testParsePackedFromUnpacked.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testParseUnpackedFromPacked.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeAllExtensions.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeAllFields.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeAllPackedExtensions.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeAllPackedFields.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeEmtpyMessage.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeNegativeValues.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeUninitialized.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeUninitializedSubMessage.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testSerializeWithOptionalGroup.__unittest_expecting_failure__ = True +reflection_test.SerializationTest.testUnknownFields.__unittest_expecting_failure__ = True +reflection_test.TestAllTypesEqualityTest.testEmptyProtosEqual.__unittest_expecting_failure__ = True + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUp(): +# +# NotImplementedError: access repeated +# +# TODO: change to __unittest_expecting_failure__ when repeated fields are available. +reflection_test.FullProtosEqualityTest.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=reflection_test, verbosity=2) diff --git a/python/pb_unit_tests/service_reflection_test_wrapper.py b/python/pb_unit_tests/service_reflection_test_wrapper.py new file mode 100644 index 0000000000..089779a3d1 --- /dev/null +++ b/python/pb_unit_tests/service_reflection_test_wrapper.py @@ -0,0 +1,30 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import service_reflection_test +import unittest + +if __name__ == '__main__': + unittest.main(module=service_reflection_test, verbosity=2) diff --git a/python/pb_unit_tests/symbol_database_test_wrapper.py b/python/pb_unit_tests/symbol_database_test_wrapper.py new file mode 100644 index 0000000000..815328e4d5 --- /dev/null +++ b/python/pb_unit_tests/symbol_database_test_wrapper.py @@ -0,0 +1,39 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import symbol_database_test +import unittest + +symbol_database_test.SymbolDatabaseTest.testEnums.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testFindFileByName.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testFindFileContainingSymbol.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testFindMessageTypeByName.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testFindServiceByName.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testGetMessages.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testGetPrototype.__unittest_expecting_failure__ = True +symbol_database_test.SymbolDatabaseTest.testGetSymbol.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=symbol_database_test, verbosity=2) diff --git a/python/pb_unit_tests/text_encoding_test_wrapper.py b/python/pb_unit_tests/text_encoding_test_wrapper.py new file mode 100644 index 0000000000..3c567bcb94 --- /dev/null +++ b/python/pb_unit_tests/text_encoding_test_wrapper.py @@ -0,0 +1,30 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import text_encoding_test +import unittest + +if __name__ == '__main__': + unittest.main(module=text_encoding_test, verbosity=2) diff --git a/python/pb_unit_tests/text_format_test_wrapper.py b/python/pb_unit_tests/text_format_test_wrapper.py new file mode 100644 index 0000000000..f2bc50b4ef --- /dev/null +++ b/python/pb_unit_tests/text_format_test_wrapper.py @@ -0,0 +1,247 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import text_format_test +import unittest +from google.protobuf.internal import _parameterized + +sep = _parameterized._SEPARATOR + +text_format_test.OnlyWorksWithProto2RightNowTests.testDuplicateMapKey.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testMapOrderEnforcement.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testMergeLinesGolden.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testParseGolden.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testParseLinesGolden.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testPrintAllFields.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testPrintAllFieldsPointy.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testPrintInIndexOrder.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testPrintMap.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testPrintMapUsingCppImplementation.__unittest_expecting_failure__ = True +text_format_test.OnlyWorksWithProto2RightNowTests.testPrintUnknownFields.__unittest_expecting_failure__ = True +text_format_test.OptionalColonMessageToStringTest.testForcePrintOptionalColon.__unittest_expecting_failure__ = True +text_format_test.OptionalColonMessageToStringTest.testPrintShortFormatRepeatedFields.__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintMultiLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintMultiLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintMultiLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintMultiLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintMultipleParts" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintMultipleParts" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintNoMatch" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintNoMatch" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.PrettyPrinterTest, "testPrettyPrintOneLine" + sep + "1").__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testExtensionInsideAnyMessage.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testMergeDuplicateExtensionScalars.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseAllExtensions.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseAllowedUnknownExtension.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseBadExtension.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseDuplicateExtensionMessages.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseDuplicateExtensionScalars.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseGoldenExtensions.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseGroupNotClosed.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseMap.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseMessageByFieldNumber.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testParseMessageSet.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testPrintAllExtensions.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testPrintAllExtensionsPointy.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testPrintMessageSet.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testPrintMessageSetAsOneLine.__unittest_expecting_failure__ = True +text_format_test.Proto2Tests.testPrintMessageSetByFieldNumber.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeAlternativeUrl.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeExpandedAny.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeExpandedAnyDescriptorPoolMissingType.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeExpandedAnyPointyBrackets.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeExpandedAnyRepeated.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeMissingAnyEndToken.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testMergeUnexpandedAny.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintAndParseMessageInvalidAny.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintMessageExpandAny.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintMessageExpandAnyAsOneLine.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintMessageExpandAnyAsOneLinePointyBrackets.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintMessageExpandAnyDescriptorPoolMissingType.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintMessageExpandAnyPointyBrackets.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testPrintMessageExpandAnyRepeated.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testProto3Optional.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testTopAnyMessage.__unittest_expecting_failure__ = True +text_format_test.Proto3Tests.testUnknownEnums.__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testMergeDuplicateNestedMessageScalars" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMergeTests, "testReplaceMessageInMessage" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testCustomOptions" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringASCII" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringASCII" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringASCII" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringASCII" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringUnicode" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringUnicode" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringUnicode" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testMessageToStringUnicode" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticUnicodeSubclass" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticUnicodeSubclass" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticUnicodeSubclass" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExoticUnicodeSubclass" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExotic" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExotic" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExotic" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintExotic" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatFormat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatFormat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatFormat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatFormat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatPrecision" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatPrecision" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatPrecision" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintFloatPrecision" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedMessageAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedMessageAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedMessageAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedMessageAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedNewLineInStringAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedNewLineInStringAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedNewLineInStringAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintNestedNewLineInStringAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRawUtf8String" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRawUtf8String" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRawUtf8String" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRawUtf8String" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRepeatedFieldsAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRepeatedFieldsAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRepeatedFieldsAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintRepeatedFieldsAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintShortFormatRepeatedFields" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintShortFormatRepeatedFields" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintShortFormatRepeatedFields" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintShortFormatRepeatedFields" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintUnknownFieldsEmbeddedMessageInBytes" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintUnknownFieldsEmbeddedMessageInBytes" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintUnknownFieldsEmbeddedMessageInBytes" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testPrintUnknownFieldsEmbeddedMessageInBytes" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testRoundTripExoticAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testRoundTripExoticAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testRoundTripExoticAsOneLine" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToStringTests, "testRoundTripExoticAsOneLine" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testEscapedUtf8ASCIIRoundTrip" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testEscapedUtf8ASCIIRoundTrip" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testEscapedUtf8ASCIIRoundTrip" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testEscapedUtf8ASCIIRoundTrip" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testMessageToBytes" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testMessageToBytes" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testMessageToBytes" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testMessageToBytes" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testRawUtf8RoundTrip" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testRawUtf8RoundTrip" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testRawUtf8RoundTrip" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatMessageToTextBytesTests, "testRawUtf8RoundTrip" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesFile" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesFile" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesFile" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesFile" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesLines" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesLines" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesLines" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromBytesLines" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeFile" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeFile" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeFile" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeFile" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeLines" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeLines" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeLines" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testFromUnicodeLines" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAllFields" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAllFields" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAllFields" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAllFields" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAndMergeUtf8" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAndMergeUtf8" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAndMergeUtf8" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseAndMergeUtf8" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseBytes" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseBytes" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseBytes" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseBytes" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseDoubleToFloat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseDoubleToFloat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseDoubleToFloat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseDoubleToFloat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseEmptyText" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseEmptyText" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseEmptyText" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseEmptyText" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseExotic" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseExotic" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseExotic" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseExotic" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseOneof" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedMessageShortFormat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedScalarShortFormat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedScalarShortFormat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedScalarShortFormat" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseRepeatedScalarShortFormat" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseStringFieldUnescape" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseStringFieldUnescape" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseStringFieldUnescape" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseStringFieldUnescape" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseTrailingCommas" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseTrailingCommas" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseTrailingCommas" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseTrailingCommas" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnicode" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnicode" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnicode" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnicode" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "1").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "0").__unittest_expecting_failure__ = True +getattr(text_format_test.TextFormatParserTests, "testParseUnknownField" + sep + "1").__unittest_expecting_failure__ = True + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUp(): +# +# NotImplementedError: Conversion of message types not yet implemented +# +# TODO: change to __unittest_expecting_failure__ when message types can be converted +text_format_test.WhitespaceTest.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=text_format_test, verbosity=2) diff --git a/python/pb_unit_tests/unknown_fields_test_wrapper.py b/python/pb_unit_tests/unknown_fields_test_wrapper.py new file mode 100644 index 0000000000..6888d3641d --- /dev/null +++ b/python/pb_unit_tests/unknown_fields_test_wrapper.py @@ -0,0 +1,58 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import unknown_fields_test +import unittest + +# We must skip these tests entirely (rather than running them with +# __unittest_expecting_failure__) because they error out in setUp(): +# +# NotImplementedError: access repeated +# +# TODO: change to __unittest_expecting_failure__ when repeated fields are available +unknown_fields_test.UnknownEnumValuesTest.testCheckUnknownFieldValueForEnum.__unittest_skip__ = True +unknown_fields_test.UnknownEnumValuesTest.testRoundTrip.__unittest_skip__ = True +unknown_fields_test.UnknownEnumValuesTest.testUnknownEnumValue.__unittest_skip__ = True +unknown_fields_test.UnknownEnumValuesTest.testUnknownPackedEnumValue.__unittest_skip__ = True +unknown_fields_test.UnknownEnumValuesTest.testUnknownParseMismatchEnumValue.__unittest_skip__ = True +unknown_fields_test.UnknownEnumValuesTest.testUnknownRepeatedEnumValue.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testCheckUnknownFieldValue.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testClear.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testCopyFrom.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testMergeFrom.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testSubUnknownFields.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testUnknownExtensions.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testUnknownField.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsAccessorsTest.testUnknownFieldsNoMemoryLeak.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testByteSize.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testDiscardUnknownFields.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testEquals.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testListFields.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testSerialize.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testSerializeMessageSetWireFormatUnknownExtension.__unittest_skip__ = True +unknown_fields_test.UnknownFieldsTest.testSerializeProto3.__unittest_skip__ = True + +if __name__ == '__main__': + unittest.main(module=unknown_fields_test, verbosity=2) diff --git a/python/pb_unit_tests/well_known_types_test_wrapper.py b/python/pb_unit_tests/well_known_types_test_wrapper.py new file mode 100644 index 0000000000..eaef5085a1 --- /dev/null +++ b/python/pb_unit_tests/well_known_types_test_wrapper.py @@ -0,0 +1,51 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import well_known_types_test +import unittest + +well_known_types_test.AnyTest.testAnyMessage.__unittest_expecting_failure__ = True +well_known_types_test.AnyTest.testPackDeterministic.__unittest_expecting_failure__ = True +well_known_types_test.AnyTest.testPackWithCustomTypeUrl.__unittest_expecting_failure__ = True +well_known_types_test.AnyTest.testUnpackWithNoSlashInTypeUrl.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testCanonicalFrom.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testDescriptorToFieldMask.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testIntersect.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testIsValidForDescriptor.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testMergeErrors.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testMergeMessageWithMapField.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testMergeMessageWithoutMapFields.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testStringFormat.__unittest_expecting_failure__ = True +well_known_types_test.FieldMaskTest.testUnion.__unittest_expecting_failure__ = True +well_known_types_test.StructTest.testMergeFrom.__unittest_expecting_failure__ = True +well_known_types_test.StructTest.testStruct.__unittest_expecting_failure__ = True +well_known_types_test.StructTest.testStructAssignment.__unittest_expecting_failure__ = True +well_known_types_test.TimeUtilTest.testDatetimeConversionWithTimezone.__unittest_expecting_failure__ = True +well_known_types_test.TimeUtilTest.testDurationSerializeAndParse.__unittest_expecting_failure__ = True +well_known_types_test.TimeUtilTest.testTimedeltaConversion.__unittest_expecting_failure__ = True +well_known_types_test.TimeUtilTest.testTimestampSerializeAndParse.__unittest_expecting_failure__ = True + +if __name__ == '__main__': + unittest.main(module=well_known_types_test, verbosity=2) diff --git a/python/pb_unit_tests/wire_format_test_wrapper.py b/python/pb_unit_tests/wire_format_test_wrapper.py new file mode 100644 index 0000000000..c2f6c0acd6 --- /dev/null +++ b/python/pb_unit_tests/wire_format_test_wrapper.py @@ -0,0 +1,30 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Google LLC nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from google.protobuf.internal import wire_format_test +import unittest + +if __name__ == '__main__': + unittest.main(module=wire_format_test, verbosity=2) diff --git a/python/protobuf.c b/python/protobuf.c index 09b1552db9..53c3f9c264 100644 --- a/python/protobuf.c +++ b/python/protobuf.c @@ -25,11 +25,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "protobuf.h" +#include "python/protobuf.h" -#include "descriptor.h" -#include "descriptor_containers.h" -#include "descriptor_pool.h" +#include "python/descriptor.h" +#include "python/descriptor_containers.h" +#include "python/descriptor_pool.h" +#include "python/message.h" static void PyUpb_ModuleDealloc(void *module) { PyUpb_ModuleState *s = PyModule_GetState(module); From 3921e0299018d878603925f79f655648ad5ff2cb Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 27 Dec 2021 18:29:39 -0800 Subject: [PATCH 4/6] Fixed make_cmakelists.py. --- cmake/make_cmakelists.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/make_cmakelists.py b/cmake/make_cmakelists.py index dea43974ed..341f095c2b 100755 --- a/cmake/make_cmakelists.py +++ b/cmake/make_cmakelists.py @@ -223,6 +223,9 @@ class WorkspaceFileFunctions(object): def system_python(self, **kwargs): pass + def register_toolchains(self, toolchain): + pass + class Converter(object): def __init__(self): From da71fdeeb2dfc0daf693582acedc891d0284c50f Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 27 Dec 2021 19:07:29 -0800 Subject: [PATCH 5/6] Addressed PR comments. --- python/descriptor_containers.c | 4 +- python/pb_unit_tests/BUILD | 256 ++++++++++++++++++++++++++++----- 2 files changed, 221 insertions(+), 39 deletions(-) diff --git a/python/descriptor_containers.c b/python/descriptor_containers.c index 22b201dbe2..95d2da10f3 100644 --- a/python/descriptor_containers.c +++ b/python/descriptor_containers.c @@ -167,10 +167,9 @@ static int PyUpb_GenericSequence_IsEqual(PyUpb_GenericSequence *self, } PyObject *item1; - PyObject *item2; for (int i = 0; i < n; i++) { item1 = PyUpb_GenericSequence_GetItem((PyObject*)self, i); - item2 = PyList_GetItem(other, i); + PyObject* item2 = PyList_GetItem(other, i); if (!item1 || !item2) goto error; int cmp = PyObject_RichCompareBool(item1, item2, Py_EQ); Py_DECREF(item1); @@ -181,7 +180,6 @@ static int PyUpb_GenericSequence_IsEqual(PyUpb_GenericSequence *self, error: Py_XDECREF(item1); - Py_XDECREF(item2); return -1; } diff --git a/python/pb_unit_tests/BUILD b/python/pb_unit_tests/BUILD index 4a32c4ba10..6a8143b701 100644 --- a/python/pb_unit_tests/BUILD +++ b/python/pb_unit_tests/BUILD @@ -23,39 +23,223 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -TESTS = [ - "descriptor_database_test", - "descriptor_pool_test", - "descriptor_test", - "generator_test", - "json_format_test", - "keywords_test", - "message_factory_test", - "message_test", - "proto_builder_test", - "reflection_test", - "service_reflection_test", - "symbol_database_test", - "text_encoding_test", - "text_format_test", - "unknown_fields_test", - "well_known_types_test", - "wire_format_test", -] - -[ - py_test( - name = test, - main = test + "_wrapper.py", - srcs = [ - test + "_wrapper.py", - ], - deps = [ - "//python:message_ext", - "@com_google_protobuf//:python_srcs", - "@com_google_protobuf//:python_common_test_protos", - "@com_google_protobuf//:python_specific_test_protos", - ], - legacy_create_init = False, - ) for test in TESTS -] +py_test( + name = "descriptor_database_test", + main = "descriptor_database_test_wrapper.py", + srcs = ["descriptor_database_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "descriptor_pool_test", + main = "descriptor_pool_test_wrapper.py", + srcs = ["descriptor_pool_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "descriptor_test", + main = "descriptor_test_wrapper.py", + srcs = ["descriptor_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "generator_test", + main = "generator_test_wrapper.py", + srcs = ["generator_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "json_format_test", + main = "json_format_test_wrapper.py", + srcs = ["json_format_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "keywords_test", + main = "keywords_test_wrapper.py", + srcs = ["keywords_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "message_factory_test", + main = "message_factory_test_wrapper.py", + srcs = ["message_factory_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "message_test", + main = "message_test_wrapper.py", + srcs = ["message_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "proto_builder_test", + main = "proto_builder_test_wrapper.py", + srcs = ["proto_builder_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "reflection_test", + main = "reflection_test_wrapper.py", + srcs = ["reflection_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "service_reflection_test", + main = "service_reflection_test_wrapper.py", + srcs = ["service_reflection_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "symbol_database_test", + main = "symbol_database_test_wrapper.py", + srcs = ["symbol_database_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "text_encoding_test", + main = "text_encoding_test_wrapper.py", + srcs = ["text_encoding_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "text_format_test", + main = "text_format_test_wrapper.py", + srcs = ["text_format_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "unknown_fields_test", + main = "unknown_fields_test_wrapper.py", + srcs = ["unknown_fields_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "well_known_types_test", + main = "well_known_types_test_wrapper.py", + srcs = ["well_known_types_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) + +py_test( + name = "wire_format_test", + main = "wire_format_test_wrapper.py", + srcs = ["wire_format_test_wrapper.py"], + deps = [ + "//python:message_ext", + "@com_google_protobuf//:python_srcs", + "@com_google_protobuf//:python_common_test_protos", + "@com_google_protobuf//:python_specific_test_protos", + ], + legacy_create_init = False, +) From 1258c61138e4a646058322296b95049610519280 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 27 Dec 2021 19:26:43 -0800 Subject: [PATCH 6/6] Exclude all Python tests from ASAN at the moment. I would like to enabled ASAN here, but it is tricky to do so. --- .github/workflows/bazel_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bazel_tests.yml b/.github/workflows/bazel_tests.yml index d43fa7f879..062342aeea 100644 --- a/.github/workflows/bazel_tests.yml +++ b/.github/workflows/bazel_tests.yml @@ -22,7 +22,7 @@ jobs: - { CC: clang, os: ubuntu-20.04, flags: "-c opt" } # Some warnings only fire with -c opt - { CC: gcc, os: ubuntu-20.04, flags: "-c opt" } - { CC: clang, os: ubuntu-20.04, flags: "--//:fasttable_enabled=true -- -cmake:test_generated_files" } - - { CC: clang, os: ubuntu-20.04, flags: "--config=asan -- -benchmarks:benchmark -python:all" } + - { CC: clang, os: ubuntu-20.04, flags: "--config=asan -- -benchmarks:benchmark -python/..." } - { CC: clang, os: macos-11, flags: "" } steps: