Repository navigation
Conversation
|
I noticed the added test was not run at all at CI. I fixed that. I also moved the test to the core tests. |
pekkaklarck
left a comment
There was a problem hiding this comment.
Are you sure the current behavior isn't already covered by tests? I would be surprised if it wasn't, but I can certainly be wrong.
See also my comment about the documentation change.
| a new instance is created every time regardless the scope. | ||
| a new instance is created every time regardless the scope. If a | ||
| library is imported multiple times using the same destination | ||
| the initial instance remains available unaffected by the new imports. |
There was a problem hiding this comment.
The proposed wording, especially "same destination" sounds a bit odd for me. Could it something like this be better:
If a library is imported multiple times using same arguments, subsequent imports are ignored.
There was a problem hiding this comment.
The problem is that subsequent imports do not get ignored. If they would get ignored, and ideally a warning generated, the situation would be much better.
They do happen, and the __init__ code gets executed, which leaves robotframework in a Frankenstein situation where the global state of the last, and the object of the first import attempt to work together, which is confusing at least.
It gets worse when while debugging someone reads the logs buttom up. The newest __init__ call is found first, and both global and object state are logged in a consistent state, adding to the confusion.
I think this is unintuitive, and I believe it should be clearly documented.
If multiple destinations are used, the situation becomes much less confusing, as there are multiple objects, one of which is consistent with global state, the others are not. This bug behaves in robotframework the same way as it would in python, much easier to deal with.
If no global state is involved with multiple destinations, the behaviour is actually the way I would expect it to be.
I do not know. I did not spend a lot of time looking for preexisitng tests for this topic, but I did not stumble on them. |
this issue reminded me that there is a wired situation that is a bit hard to understand and might benefit from a more verbose documentation
When you load the same library repeated times on the same "AS" name.
All of them get performed from top to button
But the initial one is accessible under the name.
The same applies when using Import Library
Doing this is in my point of view not a good idea. However, documenting this property would have helped me when analyzing/debugging in the past.
There is a risk by documenting this to make this behavior a requirement hindering future developments. In that case it would be a reasonable alternative to declare the behaviour undefined. The problem for me is that the sentence.:
If a library is imported multiple times with different arguments, a new instance is created every time regardless the scope.
can be misunderstood to imply that the created instance is also assigned.