Title: test: strict positional parameter enforcement is ignored under pytest · Issue #2755 · googleapis/google-api-python-client · GitHub
Open Graph Title: test: strict positional parameter enforcement is ignored under pytest · Issue #2755 · googleapis/google-api-python-client
X Title: test: strict positional parameter enforcement is ignored under pytest · Issue #2755 · googleapis/google-api-python-client
Description: Environment details OS type and version: Linux (gLinux / Debian based) Python version: 3.13.12 (also affects all supported Python versions 3.10+) pip version: 26.0.1 google-api-python-client version: 2.197.0 (at commit 6e471c075039dfef24...
Open Graph Description: Environment details OS type and version: Linux (gLinux / Debian based) Python version: 3.13.12 (also affects all supported Python versions 3.10+) pip version: 26.0.1 google-api-python-client versio...
X Description: Environment details OS type and version: Linux (gLinux / Debian based) Python version: 3.13.12 (also affects all supported Python versions 3.10+) pip version: 26.0.1 google-api-python-client versio...
Opengraph URL: https://github.com/googleapis/google-api-python-client/issues/2755
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test: strict positional parameter enforcement is ignored under pytest","articleBody":"#### Environment details\n\n - OS type and version: Linux (gLinux / Debian based)\n - Python version: `3.13.12` (also affects all supported Python versions `3.10+`)\n - pip version: `26.0.1`\n - `google-api-python-client` version: `2.197.0` (at commit `6e471c075039dfef24e28d11658e03d5c949c7c3`)\n\n#### Steps to reproduce\n\n 1. Check out the `main` branch of `google-api-python-client`.\n 2. Set up a clean virtual environment and install test dependencies (`pytest`, `mock`, `parameterized`).\n 3. Run the strict positional parameters enforcement test directly using `pytest`:\n ```bash\n pytest tests/test_discovery.py -k test_tests_should_be_run_with_strict_positional_enforcement\n ```\n\n#### Code example\n\nThe bug lies in how strict argument enforcement is configured for the test suite in `tests/__init__.py`. \n\nHistorically, the enforcement was configured inside the nose-legacy `setup_package()` hook:\n```python\n# tests/__init__.py\nfrom googleapiclient import _helpers as util\n\ndef setup_package():\n \"\"\"Run on testing package.\"\"\"\n util.positional_parameters_enforcement = \"EXCEPTION\"\n```\n\nBecause modern test runs in this repository (including via `nox` sessions) run under **`pytest`**, the `setup_package()` package-level hook is ignored. As a result, the tests run in warning-only mode, causing strict parameter assertion tests to be bypassed and fail with an `AssertionError` instead of raising `TypeError`.\n\nSince the repository has migrated to `pytest`, this legacy hook is dead code. We should configure the variable directly at the package module level and completely remove the unused `setup_package` hook:\n\n```diff\n# tests/__init__.py\nfrom googleapiclient import _helpers as util\n\n+util.positional_parameters_enforcement = \"EXCEPTION\"\n-\n-def setup_package():\n- \"\"\"Run on testing package.\"\"\"\n- util.positional_parameters_enforcement = \"EXCEPTION\"\n```\n\n#### Stack trace\n\nWhen running the tests using `pytest`, the test fails with the following output:\n\n```\n=================================== FAILURES ===================================\n_ DiscoveryErrors.test_tests_should_be_run_with_strict_positional_enforcement __\n\nself = \u003ctests.test_discovery.DiscoveryErrors testMethod=test_tests_should_be_run_with_strict_positional_enforcement>\n\n def test_tests_should_be_run_with_strict_positional_enforcement(self):\n try:\n plus = build(\"plus\", \"v1\", None, static_discovery=False)\n> self.fail(\"should have raised a TypeError exception over missing http=.\")\nE AssertionError: should have raised a TypeError exception over missing http=.\n\ntests/test_discovery.py:509: AssertionError\n------------------------------ Captured log call -------------------------------\nWARNING googleapiclient._helpers:_helpers.py:129 build() takes at most 2 positional arguments (3 given)\n=========================== short test summary info ============================\nFAILED tests/test_discovery.py::DiscoveryErrors::test_tests_should_be_run_with_strict_positional_enforcement\n====================== 1 failed, 332 deselected in 1.65s =======================\n```\n","author":{"url":"https://github.com/Capstan","@type":"Person","name":"Capstan"},"datePublished":"2026-05-31T01:20:42Z","url":"https://github.com/googleapis/google-api-python-client/issues/2755"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:252bfc7f-1e92-98ca-f752-c1a903f18422 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E652:882E2:440F6F:5C1D51:6B00C8FE |
| html-safe-nonce | 48491437e5edef25512ebf8a6f7745de83038fca6c50ca774e7a2ab2d19d97c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjUyOjg4MkUyOjQ0MEY2Rjo1QzFENTE6NkIwMEM4RkUiLCJ2aXNpdG9yX2lkIjoiMTA2OTE1ODA5OTI1Nzk2ODg5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1aa35a8cc575a486c3a1706eb62d96584834913bc605132922b8664657fd1cb1 |
| hovercard-subject-tag | issue:4556218893 |
| 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/google-api-python-client/2755/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b132b2d514530048eb2725fa17ab18ee800cf76d7a00259db782a93ab501ea0e/googleapis/google-api-python-client/issues/2755 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b132b2d514530048eb2725fa17ab18ee800cf76d7a00259db782a93ab501ea0e/googleapis/google-api-python-client/issues/2755 |
| og:image:alt | Environment details OS type and version: Linux (gLinux / Debian based) Python version: 3.13.12 (also affects all supported Python versions 3.10+) pip version: 26.0.1 google-api-python-client versio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Capstan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-api-python-client git https://github.com/googleapis/google-api-python-client.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 15749269 |
| octolytics-dimension-repository_nwo | googleapis/google-api-python-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 15749269 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-api-python-client |
| 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 | ef013399cf0a3c324bea644a685d7c1e0f06b5b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width