You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
In the example above, it seems that the response message was properly populated with import_.Import(...) within its container field, but the method's _ref_types attribute did not include import_.
To reproduce, add a fragment file:
Then run
nox -s fragment-3.7 -- tests/fragments/broken.proto. The generated unit test fails withNameError: name 'import_' is not defined.Some variants of similar protos do not fail:
oneofis removed.Container container = 1;is replaced with justImport import = 1;.Import import = 1;is replaced with a field of primitive data type, e.g.string import = 1;.MethodResponseis empty, and theoneofis moved intoMethodRequest. (This seems to be incidental to the implementation of unit test generation.)Two pieces of generator code are relevant here:
_ref_types. It is used in the template to add import statements: https://github.com/googleapis/gapic-generator-python/blob/v1.10.0/gapic/templates/tests/unit/gapic/%25name_%25version/%25sub/test_%25service.py.j2#L65call.return_value: https://github.com/googleapis/gapic-generator-python/blob/v1.10.0/gapic/templates/tests/unit/gapic/%25name_%25version/%25sub/test_macros.j2#L35In the example above, it seems that the response message was properly populated with
import_.Import(...)within itscontainerfield, but the method's_ref_typesattribute did not includeimport_.