Skip to content

[v2] Raise TypeError on bare test decorator usage, fix bare @requires_crt usages, and add regression tests#10131

Merged
Alan4506 merged 1 commit intoaws:v2from
Alan4506:v2_requires_crt_fix
Mar 17, 2026
Merged

[v2] Raise TypeError on bare test decorator usage, fix bare @requires_crt usages, and add regression tests#10131
Alan4506 merged 1 commit intoaws:v2from
Alan4506:v2_requires_crt_fix

Conversation

@Alan4506
Copy link
Contributor

Background:
@skip_if_windows, @skip_if_using_serial_implementation, and @requires_crt are decorator factories in tests/utils/s3transfer/__init__.py for cli v2.

@skip_if_windows and @skip_if_using_serial_implementation are decorator factories that require parentheses. If they are used without parentheses (e.g., bare @skip_if_using_serial_implementation), this is unsafe because Python passes the test function as the first argument, causing the real test body to never run. Assertions are never evaluated, but the test may still appear to pass or skip silently. However, these two did not raise an error on bare usage.

On the other hand, @requires_crt in cli v2 only worked correctly with bare usage, while cli v1, botocore, boto3, and s3transfer already required the parenthesized form @requires_crt(). This cross-repo inconsistency creates a maintainer footgun because contributors move between repos and assume the decorator behaves the same way everywhere. It needs to be standardized to only accept the parenthesized form and all existing bare usages need to be updated.

Note: requires_crt_pytest in tests/unit/s3transfer/test_crt.py is a pytest.mark.skipif object, not a decorator factory. Bare usage is the correct form for it and is not affected by this change. Similarly, there is another skip_if_windows defined in tests/markers.py which is also a pytest.mark.skipif object and is not affected.

Description of changes:
All three decorator factories in tests/utils/s3transfer/__init__.py now raise a TypeError on bare usage. @requires_crt is updated to only accept the parenthesized form for consistency with the other two decorators in this repo as well as cli v1 and other repos. All existing bare @requires_crt usages across test files are updated to @requires_crt().

Testing:
Regression tests are added in tests/unit/test_decorators.py to verify correct behavior for all three decorators. All tests including the new tests pass.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Alan4506 Alan4506 added the v2 label Mar 13, 2026
@Alan4506 Alan4506 changed the title Raise TypeError on bare test decorator usage, fix bare @requires_crt usages, and add regression tests [v2] Raise TypeError on bare test decorator usage, fix bare @requires_crt usages, and add regression tests Mar 13, 2026
@Alan4506 Alan4506 merged commit 2eeff37 into aws:v2 Mar 17, 2026
127 of 136 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants