-
Notifications
You must be signed in to change notification settings - Fork 763
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
Return value of Register keyword to run on failure
cannot always be used to restore original state
#176
Comments
I think that changing the return value is an unnecessary and a riskier change. When this was first implemented, it should have returned "nothing", but it seems too late to change that. If we consider "No keyword" and "nothing" to be synonymous, the warning will go away. |
I just stumbled on this today. This really ought to be fixed. I shouldn't have to add special case code in my test when saving and restoring the keyword. If changing the return value is unacceptable, perhaps changing it so that passing in "No Keyword" has the same effect as passing in "Nothing". I shouldn't have to have special case code in my tests and keywords in case there is no keyword registered. In other words, the following should always return the system to the correct state:
|
Ugh I agree, would you like to make a pull requests to fix it? -Tatu -----Original Message----- I just stumbled on this today. This really ought to be fixed. I shouldn't have to add special case code in my test when saving and restoring the keyword. If changing the return value is unacceptable, perhaps changing it so that passing in "No Keyword" has the same effect as passing in "Nothing". |
Perhaps easy fix could be change the |
This should have deprecated this in 3.0 Alpha release. We will make at least one release candidate, perhaps deprecation could be done in there. Adding this to 3.0.0 milestone. |
We are not going to deprecate the old functionality, instead we are going to change the functionality. |
1. Return value from `Register keyword to run on failure` can now always be used as an argument to the keyword. In practice the keyword nowadays returns `None` if the functionality was disabled and `None` (as well as `'NONE'`) can be used to disable the functionality. Fixes robotframework#176. 2. Moved the hook method to run when a keyword fails to the core. This simplifies implementation. The hook method was also renamed from `run_on_failure` to `failure_occurred`.
My changes in #884 change the behavior like this:
The change is to some extend backwards incompatible, because the earlier |
Register keyword to run on failure
cannot always be used to restore original state
On a second though I don't think it is useful to support any value considered false on Python when disabling this functionality. Supporting just |
Also changed disabling this functionality not to work with any false value. That's related to robotframework#176.
Also changed disabling this functionality not to work with any false value. That's related to #176.
There seems to be an issue with the implementation of the "Register keyword to run on failure" keyword. The keyword returns the value of the previously registered keyword which works fine if this is set to a keyword e.g. "Capture Page Screenshot" but if the registered keyword is set to "None" the return value is the string "No keyword". If you then try to use the return value "No keyword" and pass this back into "Register keyword to run on failure" a warning is generated:
"Keyword 'No keyword' could not be run on failure: No keyword with name 'No keyword' found."
I guess this keyword should either be returning "Nothing" as a string rather than "No keyword" to be consistent with the current way of disabling the run-on-failure functionality or it could return None instead
Example test case (simplistic example):
The implementation could be changed to the following which would return None from line 2 of the above test case and no warnings are observed on failure:
The text was updated successfully, but these errors were encountered: