test: strict positional parameter enforcement is ignored under pytest
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 92/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu trong tests/init.py, sau đó chạy tests/test_discovery.py với pytest và bộ lọc -k test_tests_should_be_run_with_strict_positional_enforcement. Xác minh rằng bài kiểm thử tham số vị trí nghiêm ngặt tạo ra TypeError và đạt, đồng thời lần chạy kiểm thử rộng hơn với pytest hoặc nox vẫn xanh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment details
- OS type and version: Linux (gLinux / Debian based)
- Python version:
3.13.12(also affects all supported Python versions3.10+) - pip version:
26.0.1 google-api-python-clientversion:2.197.0(at commit6e471c075039dfef24e28d11658e03d5c949c7c3)
Steps to reproduce
- Check out the
mainbranch ofgoogle-api-python-client. - Set up a clean virtual environment and install test dependencies (
pytest,mock,parameterized). - Run the strict positional parameters enforcement test directly using
pytest:pytest tests/test_discovery.py -k test_tests_should_be_run_with_strict_positional_enforcement
Code example
The bug lies in how strict argument enforcement is configured for the test suite in tests/__init__.py.
Historically, the enforcement was configured inside the nose-legacy setup_package() hook:
# tests/__init__.py
from googleapiclient import _helpers as util
def setup_package():
"""Run on testing package."""
util.positional_parameters_enforcement = "EXCEPTION"
Because 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.
Since 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:
# tests/__init__.py
from googleapiclient import _helpers as util
+util.positional_parameters_enforcement = "EXCEPTION"
-
-def setup_package():
- """Run on testing package."""
- util.positional_parameters_enforcement = "EXCEPTION"
Stack trace
When running the tests using pytest, the test fails with the following output:
=================================== FAILURES ===================================
_ DiscoveryErrors.test_tests_should_be_run_with_strict_positional_enforcement __
self = <tests.test_discovery.DiscoveryErrors testMethod=test_tests_should_be_run_with_strict_positional_enforcement>
def test_tests_should_be_run_with_strict_positional_enforcement(self):
try:
plus = build("plus", "v1", None, static_discovery=False)
> self.fail("should have raised a TypeError exception over missing http=.")
E AssertionError: should have raised a TypeError exception over missing http=.
tests/test_discovery.py:509: AssertionError
------------------------------ Captured log call -------------------------------
WARNING googleapiclient._helpers:_helpers.py:129 build() takes at most 2 positional arguments (3 given)
=========================== short test summary info ============================
FAILED tests/test_discovery.py::DiscoveryErrors::test_tests_should_be_run_with_strict_positional_enforcement
====================== 1 failed, 332 deselected in 1.65s =======================
- Ngôn ngữ chính
- Python
- Star
- 8.9k
- Fork
- 2.6k
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-api-python-client
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
googleapis/google-api-python-client#2788 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
test: connection leak test test_discovery_http_is_closed is shadowed and syntactically invalidĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
googleapis/google-api-python-client#2757 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
forms for APĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
googleapis/google-api-python-client#2830 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
googleapis/google-api-python-client#2825 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
เมตาแมสĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 10/100
googleapis/google-api-python-client#2824 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-api-python-client
Issue tương tự
-
P4: low tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
jeffknupp/association#318 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
petercorke/robotics-toolbox-python#709 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
MakerYuichi/Aegis-pro#114 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mpfaffenberger/code_puppy#985 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày