Title: Test regression when grpcio is installed but grpcio-status is not · Issue #301 · googleapis/python-api-core · GitHub
Open Graph Title: Test regression when grpcio is installed but grpcio-status is not · Issue #301 · googleapis/python-api-core
X Title: Test regression when grpcio is installed but grpcio-status is not · Issue #301 · googleapis/python-api-core
Description: CC @atulep The following commit causes a regression in the test suite: commit ef6f0fcfdfe771172056e35e3c990998b3b00416 Author: Aza Tulepbergenov
Open Graph Description: CC @atulep The following commit causes a regression in the test suite: commit ef6f0fcfdfe771172056e35e3c990998b3b00416 Author: Aza Tulepbergenov
X Description: CC @atulep The following commit causes a regression in the test suite: commit ef6f0fcfdfe771172056e35e3c990998b3b00416 Author: Aza Tulepbergenov <aza.tulepber@gmail.com> Date: 2021-10-19 20:1...
Opengraph URL: https://github.com/googleapis/python-api-core/issues/301
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Test regression when grpcio is installed but grpcio-status is not","articleBody":"CC @atulep \r\n\r\nThe following commit causes a regression in the test suite:\r\n```\r\ncommit ef6f0fcfdfe771172056e35e3c990998b3b00416\r\nAuthor: Aza Tulepbergenov \u003caza.tulepber@gmail.com\u003e\r\nDate: 2021-10-19 20:17:49 +0200\r\n\r\n feat: add 'GoogleAPICallError.error_details' property (#286)\r\n \r\n Based on 'google.rpc.status.details'.\r\n```\r\n\r\nPrior to this commit, the package handled both missing and present `grpc` consistently. However, the following condition in `exceptions.py`:\r\n\r\n```\r\ntry:\r\n import grpc\r\n from grpc_status import rpc_status\r\nexcept ImportError: # pragma: NO COVER\r\n grpc = None\r\n rpc_status = None\r\n```\r\n\r\nmeans that if `grpc_status` module is not installed, the exception module behaves as if `grpc` wasn't present even though other modules (notably tests) behave as if it was present. As a result, people having one but not the other module installed get a bunch of test failures because grpc-based tests are run but e.g. the `exception` module's `from_grpc_error()` function fails since `grpc` is forced to `None`.\r\n\r\nThis is especially problematic since `grpcio-status` is a new optional dependency, and since it's not packaged on Gentoo, we'd effectively have to force people to uninstall `grpcio`.\r\n\r\n#### Environment details\r\n\r\n - OS type and version: Gentoo Linux\r\n - Python version: `python --version` 3.8.12, 3.9.7\r\n - pip version: `pip --version` n/a\r\n - `google-api-core` version: `pip show google-api-core` 2.2.0, 2.2.1, git master (d2a729e0c42039bfbcd4b59c3d97d8759a9f0d57)\r\n\r\n#### Steps to reproduce\r\n\r\n 1. `git clone https://github.com/googleapis/python-api-core`\r\n 2. `cd python-api-core`\r\n 3. `python3.9 -m venv .venv`\r\n 4. `. .venv/bin/activate`\r\n 5. `pip install . grpcio pytest mock proto-plus pytest-asyncio`\r\n 6. `pytest`\r\n\r\n#### Stack trace\r\nExample test failure:\r\n```\r\n_______________________________________________________ test_wrap_unary_errors ________________________________________________________\r\n\r\nself = \u003cgoogle.api_core.grpc_helpers_async._WrappedUnaryUnaryCall object at 0x7fe0e3de3790\u003e\r\n\r\n def __await__(self):\r\n try:\r\n\u003e response = yield from self._call.__await__()\r\n\r\n.venv/lib/python3.9/site-packages/google/api_core/grpc_helpers_async.py:84: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\n_mock_self = \u003cAsyncMock id='140603872279952'\u003e, args = (1, 2), kwargs = {'three': 'four'}, self = \u003cAsyncMock id='140603872279952'\u003e\r\n_call = call(1, 2, three='four'), effect = RpcErrorImpl()\r\n\r\n async def _execute_mock_call(_mock_self, *args, **kwargs):\r\n self = _mock_self\r\n # This is nearly just like super(), except for special handling\r\n # of coroutines\r\n \r\n _call = _Call((args, kwargs), two=True)\r\n self.await_count += 1\r\n self.await_args = _call\r\n self.await_args_list.append(_call)\r\n \r\n effect = self.side_effect\r\n if effect is not None:\r\n if _is_exception(effect):\r\n\u003e raise effect\r\nE tests.asyncio.test_grpc_helpers_async.RpcErrorImpl\r\n\r\n.venv/lib/python3.9/site-packages/mock/mock.py:2169: RpcErrorImpl\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\n @pytest.mark.asyncio\r\n async def test_wrap_unary_errors():\r\n grpc_error = RpcErrorImpl(grpc.StatusCode.INVALID_ARGUMENT)\r\n callable_ = mock.AsyncMock(spec=[\"__call__\"], side_effect=grpc_error)\r\n \r\n wrapped_callable = grpc_helpers_async._wrap_unary_errors(callable_)\r\n \r\n with pytest.raises(exceptions.InvalidArgument) as exc_info:\r\n\u003e await wrapped_callable(1, 2, three=\"four\")\r\n\r\ntests/asyncio/test_grpc_helpers_async.py:57: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n.venv/lib/python3.9/site-packages/google/api_core/grpc_helpers_async.py:87: in __await__\r\n raise exceptions.from_grpc_error(rpc_error) from rpc_error\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\nrpc_exc = RpcErrorImpl()\r\n\r\n def from_grpc_error(rpc_exc):\r\n \"\"\"Create a :class:`GoogleAPICallError` from a :class:`grpc.RpcError`.\r\n \r\n Args:\r\n rpc_exc (grpc.RpcError): The gRPC error.\r\n \r\n Returns:\r\n GoogleAPICallError: An instance of the appropriate subclass of\r\n :class:`GoogleAPICallError`.\r\n \"\"\"\r\n # NOTE(lidiz) All gRPC error shares the parent class grpc.RpcError.\r\n # However, check for grpc.RpcError breaks backward compatibility.\r\n\u003e if isinstance(rpc_exc, grpc.Call) or _is_informative_grpc_error(rpc_exc):\r\nE AttributeError: 'NoneType' object has no attribute 'Call'\r\n\r\n.venv/lib/python3.9/site-packages/google/api_core/exceptions.py:532: AttributeError\r\n======================================================= short test summary info =======================================================\r\nFAILED tests/asyncio/test_grpc_helpers_async.py::test_wrap_unary_errors - AttributeError: 'NoneType' object has no attribute 'Call'\r\n```","author":{"url":"https://github.com/mgorny","@type":"Person","name":"mgorny"},"datePublished":"2021-10-28T20:50:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/301/python-api-core/issues/301"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e36f3fb3-2215-c428-9ae4-9cb3308606d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCB0:C86CC:6F4530:A22C3F:6A4E0EBD |
| html-safe-nonce | 7953bddca487412a9efe52787258fee192dc1e7fe9f883a0c358b51d892431c8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0IwOkM4NkNDOjZGNDUzMDpBMjJDM0Y6NkE0RTBFQkQiLCJ2aXNpdG9yX2lkIjoiNjMwNzQ5MTYxMDA3NTQ2NzQ1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 73a7ca4472e5fe58b866a02d2f5ec3bc4b9193a4b065f0f0d78c74c9ba96e5bd |
| hovercard-subject-tag | issue:1038942131 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-api-core/301/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf48283cf218b5a6f2e75fdc39033c60b27cbf317b8c967adb646e6ae4d22757/googleapis/python-api-core/issues/301 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf48283cf218b5a6f2e75fdc39033c60b27cbf317b8c967adb646e6ae4d22757/googleapis/python-api-core/issues/301 |
| og:image:alt | CC @atulep The following commit causes a regression in the test suite: commit ef6f0fcfdfe771172056e35e3c990998b3b00416 Author: Aza Tulepbergenov |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mgorny |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-api-core git https://github.com/googleapis/python-api-core.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992456 |
| octolytics-dimension-repository_nwo | googleapis/python-api-core |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992456 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-api-core |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 51470c353b8a1f52a88d3e3cc2014b17ab8cc1ce |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width