-
Notifications
You must be signed in to change notification settings - Fork 112
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
Runner agent is modifying nested objects causing tests to fail #127
Comments
Hi, interesting case, thanks for spotting that! Debugger is going through major changes now in order to fix couple of major problems we've had with remote debugging. However we also had issues with changing value of variables during debugging, so the area of code which provides variables to RED as well as the area responsible for changing the values have changed quite a bit already. From what I've checked now this problem is already fixed on our branch with reworked debugger, so you should see it released with next version. |
Ok, I've looked what is wrong and the problem is not in The problem lies in a) dump all the non-serializable objects to str in order to be able to send it through JSON This function recursively traverses through list/dictionaries and as you can see https://github.com/nokia/RED/blob/master/src/RobotFrameworkCore/org.robotframework.ide.core-functions/src/main/python/scripts/TestRunnerAgent.py in line 111 it makes string representation out of int type and unfortunately in line 107 it reassigns this string into the original object. In your case there is a list inside this dictionary and As I stated above - this is already fixed in development version and will be available with next RED. If you however want to fix it on your side you have to modify the source of TestRunnerAgent.py.
def _fix_unicode(max_length, data):
if sys.version_info < (3, 0, 0) and isinstance(data, unicode):
return _truncate(max_length, data.encode('utf-8'))
elif sys.version_info < (3, 0, 0) and isinstance(data, basestring):
return _truncate(max_length, data.encode('unicode_escape'))
elif sys.version_info >= (3, 0, 0) and isinstance(data, str):
return _truncate(max_length, data)
elif isinstance(data, Mapping):
return dict((_fix_unicode(max_length, k), _fix_unicode(max_length, data[k])) for k in data)
elif isinstance(data, tuple):
return tuple(list(_fix_unicode(max_length, el) for el in data))
elif isinstance(data, list):
return list(_fix_unicode(max_length, el) for el in data)
elif data is None:
return _fix_unicode(max_length, 'None')
else:
return _fix_unicode(max_length, str(data))
try:
from collections.abc import Mapping
except:
from collections import Mapping
Hope this helps! For proper fix please wait till next release. |
Thank you so much for the detailed reply and workaround. Although the upcoming fix may have resolved the issue, have you considered using I would think that would avoid accidental modification of data structures, however it would impact performance. I looked into debugging this and got lost in doing maven builds with test as the goal failing due to unresolvable host wrbboxv01.emea.nsn-net.net. |
also can't help but point out that this code would lead to some unexpected behavior if people are using
|
Good point - I was thinking about it. However given the fact that currently (in both 0.7.9 and next version) we are sending those variables pretty often which is already hitting performance I'd rather prefer to avoid copying and assure that this function will not hurt original data with usage of some suite of unit tests. On the other hand we're currently trying to change code a bit in order to send variables only when they are needed (i.e. when execution have been suspended) - if this will work we could deep copy them.
Ooopss.. sorry for that, we'll fix it - this is internal mirror of eclipse update site. It should be changed to
Thanks for spotting; someone who expect order in dictionary could be confused. We'll fix that too. |
Fixed in 0.8.0 |
RED 0.7.9
Robot Framework 3.0.1 (Python 2.7.10 on darwin)
I found that when I run in debug mode, parts of some JSON had type changed from int to the str representation of the int as soon as the JSON was assigned to a variable. This occurred in debug mode but not in run mode. This occurs even with no breakpoints set.
Here is a minimal test to reproduce the issue:
This passes in run mode but fails in debug mode with:
FAIL : int != str
I suspect the problem lies in
TestRunnerAgent._check_changed_variable
The text was updated successfully, but these errors were encountered: