-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Minor fix for #40727 #40929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor fix for #40727 #40929
Conversation
|
||
# The frame that calls this patched method (it may not be the test method) | ||
# -1: `_get_test_info`; -2: `patched_xxx`; -3: the caller to `patched_xxx` | ||
caller_frame = stack[-3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bit hardcoded, and it turns out that this causes issue when @require_read_token
is applied to a test class, where we will get
stack[-1]: _get_test_info
stack[-2]: patched
stack[-3]: wrapper
(from def require_read_token
)
stack[-4]: the caller to the method that is wrapped (in this case, it's self.assertEqual
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example is
FAILED tests/models/mistral/test_modeling_mistral.py::MistralIntegrationTest::test_speculative_generation - TypeError: 'NoneType' object is not subscriptable
where we have
@require_read_token
class MistralIntegrationTest(unittest.TestCase):
if origin_method_being_patched.__name__ in frame.line: | ||
caller_frame = frame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, we check against the name of the original method being patched.
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
* fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
* fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
* fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
What does this PR do?