-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Fragment tests fail when installing protobuf==3.20.2. This surfaced when trying to add grpcio to constraints files. It appears that we were not installing protobuf==3.20.2 when running fragment tests. This bug tracks fixing the issue. This may require bumping the minimum supported version of protobuf and the minimum supported Python runtime.
(py3112env) partheniou@partheniou-vm-3:~/git/gapic-generator-python$ nox -s fragment-3.7
nox > Running session fragment-3.7
nox > Creating virtual environment (virtualenv) using python3.7 in .nox/fragment-3-7
nox > python -m pip install coverage pytest pytest-cov pytest-xdist 'asyncmock; python_version < '"'"'3.8'"'"'' pytest-asyncio grpcio-tools
nox > python -m pip install -e .
nox > python -m pip install --upgrade grpcio
nox > python -m pip install --upgrade protobuf
nox > python -m grpc_tools.protoc --proto_path=tests/fragments --python_gapic_out=/tmp/tmpmzg8pe7f --python_gapic_opt=transport=grpc+rest,python-gapic-templates=DEFAULT test_flattened_value.proto
nox > python -m pip install /tmp/tmpmzg8pe7f -e . -qqq
nox > python -m pip install -r /tmp/tmpmzg8pe7f/testing/constraints-3.7.txt --ignore-installed
nox > py.test --quiet --cov-config=/tmp/tmpmzg8pe7f/.coveragerc --cov-report=term --cov-fail-under=100 /tmp/tmpmzg8pe7f/tests/unit
nox > Command py.test --quiet --cov-config=/tmp/tmpmzg8pe7f/.coveragerc --cov-report=term --cov-fail-under=100 /tmp/tmpmzg8pe7f/tests/unit failed with exit code 1:
........................................................F.F............. [ 58%]
................................................... [100%]
=================================== FAILURES ===================================
___________________________ test_my_method_flattened ___________________________
def test_my_method_flattened():
client = MyServiceClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.my_method),
'__call__') as call:
# Designate an appropriate return value for the call.
call.return_value = test_flattened_value.MethodResponse()
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.my_method(
parameter=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE),
> items=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)],
)
/tmp/tmpmzg8pe7f/tests/unit/gapic/fragment/test_my_service.py:942:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/tmp/tmpmzg8pe7f/google/fragment/services/my_service/client.py:670: in my_method
request.items.extend(items)
.nox/fragment-3-7/lib/python3.7/site-packages/proto/message.py:752: in __getattr__
return marshal.to_python(pb_type, pb_value, absent=key not in self)
.nox/fragment-3-7/lib/python3.7/site-packages/proto/marshal/marshal.py:193: in to_python
return self.get_rule(proto_type=proto_type).to_python(value, absent=absent)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <proto.marshal.rules.struct.ValueRule object at 0x7fcd020781d0>
value = []
def to_python(self, value, *, absent: bool = None):
"""Coerce the given value to the appropriate Python type.
Note that both NullValue and absent fields return None.
In order to disambiguate between these two options,
use containment check,
E.g.
"value" in foo
which is True for NullValue and False for an absent value.
"""
> kind = value.WhichOneof("kind")
E AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'WhichOneof'
.nox/fragment-3-7/lib/python3.7/site-packages/proto/marshal/rules/struct.py:39: AttributeError
________________________ test_my_method_flattened_async ________________________
@pytest.mark.asyncio
async def test_my_method_flattened_async():
client = MyServiceAsyncClient(
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.my_method),
'__call__') as call:
# Designate an appropriate return value for the call.
call.return_value = test_flattened_value.MethodResponse()
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(test_flattened_value.MethodResponse())
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
response = await client.my_method(
parameter=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE),
> items=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)],
)
/tmp/tmpmzg8pe7f/tests/unit/gapic/fragment/test_my_service.py:993:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/tmp/tmpmzg8pe7f/google/fragment/services/my_service/async_client.py:331: in my_method
request.items.extend(items)
.nox/fragment-3-7/lib/python3.7/site-packages/proto/message.py:752: in __getattr__
return marshal.to_python(pb_type, pb_value, absent=key not in self)
.nox/fragment-3-7/lib/python3.7/site-packages/proto/marshal/marshal.py:193: in to_python
return self.get_rule(proto_type=proto_type).to_python(value, absent=absent)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <proto.marshal.rules.struct.ValueRule object at 0x7fcd020781d0>
value = []
def to_python(self, value, *, absent: bool = None):
"""Coerce the given value to the appropriate Python type.
Note that both NullValue and absent fields return None.
In order to disambiguate between these two options,
use containment check,
E.g.
"value" in foo
which is True for NullValue and False for an absent value.
"""
> kind = value.WhichOneof("kind")
E AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'WhichOneof'
.nox/fragment-3-7/lib/python3.7/site-packages/proto/marshal/rules/struct.py:39: AttributeError
=============================== warnings summary ===============================
.nox/fragment-3-7/lib/python3.7/site-packages/grpc_tools/protoc.py:25
/usr/local/google/home/partheniou/git/gapic-generator-python/.nox/fragment-3-7/lib/python3.7/site-packages/grpc_tools/protoc.py:25: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources
.nox/fragment-3-7/lib/python3.7/site-packages/pkg_resources/__init__.py:2871
.nox/fragment-3-7/lib/python3.7/site-packages/pkg_resources/__init__.py:2871
.nox/fragment-3-7/lib/python3.7/site-packages/pkg_resources/__init__.py:2871
/usr/local/google/home/partheniou/git/gapic-generator-python/.nox/fragment-3-7/lib/python3.7/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
tests/unit/gapic/fragment/test_my_service.py: 16 warnings
/tmp/tmpmzg8pe7f/google/fragment/services/my_service/client.py:271: DeprecationWarning: get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.
DeprecationWarning)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED ../../../../../../../tmp/tmpmzg8pe7f/tests/unit/gapic/fragment/test_my_service.py::test_my_method_flattened
FAILED ../../../../../../../tmp/tmpmzg8pe7f/tests/unit/gapic/fragment/test_my_service.py::test_my_method_flattened_async
2 failed, 121 passed, 20 warnings in 1.68s
nox > Session fragment-3.7 failed.
Metadata
Metadata
Assignees
Labels
No labels