You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow giving listener and model modifier instances to robot.run and TestSuite.run #1969
As briefly discussed on IRC, I have a need to register an instance of a listener object at run-time, programmatically. I am wrapping Robot in another application, running urwid. Robot is running in a thread, and I want to update a widget based on Robot's current status. A listener would be the obvious choice for an interface between the applications.
Currently, most classes related to Listeners and logger proxies assume that the wrapped object is a string and must be imported. I have overridden some of the core classes to allow instances to be passed in.
I'm also interested on a feature like this, but my use case is a little bit different. I've sent an email in the users list: "Add listener instance using robot.api".
The idea is to be able to register a listener instance at any point in robot execution. In my use case it would be in the initialization method of robot's dynamic library (that library works as a proxy).
So the Proxy library act as a listener. Great. Now, in the init method (could be in any other), I create a bunch of instances. So what I have is something like:
(instances, keywords) =Loader().load_libraries()
Now my wish was to register each instance as a listener calling a robot API function (and was also hopping it would check for the ROBOT* attributes). It could be a BuiltIn() method/keyword? register_listener for instance.
It might be interesting to restrict scope for those instances so it receives only events from the suite they have been registered.
I see. Would it be enough is ROBOT_LIBRARY_LISTENER could be a list of listeners? That ought to be pretty easy to implement, but would require listeners to be created in __init__. An API to register listeners at any time would be more flexible and could be used also other code than libraries, but it would need a way to restrict the scope of the listener or/and have a way to unregister a listener. This would also be a new API and thus a bit more work to implement, test and document.
@spikergit1, are you also looking for an API to register listeners at any time or would being able to pass a listener instance to robot.run and TestSuite.run be enough in your use case?
@pekkaklarck being able to pass instances to robot.run and/or TestSuite.run would be enough for me, for now. I do see a benefit in "an API to register listeners at any time", and honestly having combed through the Listener code I don't think it'd be too hard to do. I could submit a PR if you're interested.
Personally I have had more needs for passing listener objects to robot.run than for having an API to register them at run time. I don't see a problem having both of these possibilities, though, and ROBOT_LIBRARY_LISTENER could be enhanced to accept a list of listeners as the third option. I consider these separate enhancements that require their own issues and possible PRs, though.
Should we agree that this issue is about passing objects to robot.run and TestSuite.run, and a new issues are submitted about possible other enhancements? If you agree, please submit issues about enhancements you care about. Please also provide PRs for issues you really care about.
Thanks @vkruoso for submitting #1970 about enhancing ROBOT_LIBRARY_LISTENER to support lists. This issue is now officially about being able to pass actual listener instances to robot.run and TestSuite.run.
We are planning to add support for visitors that can modify test suites before execution in RF 2.9 (#1976). We plan to support something like --visitor MyVisitor from the command line, similarly as with listeners, but also want to be able to pass actual visitor instances to robot.run and TestSuite.run. Same helper probably can handle both listeners and visitors so it makes sense to include also this issue in RF 2.9.
changed the title [-]Support listener instance registration[/-][+]Allow giving listener instances to `robot.run` and `TestSuite.run`[/+]on Apr 23, 2015
Now that #1993 that @WojtekKowaluk encountered when implementing this feature is fixed, it's possible to look at this issue again. We already dropped this from alpha 2 because we plan to create it tomorrow, but if we get a good PR adding this back is still possible.
Notice that the PR doesn't need to contain fixes to listeners, variable files and modifiers, just concentrating on listeners is enough. Separate PRs and possible separate issues can then be submitted about others.
PR #1987 implementing the listener part of this issue was merged in 7dd3a9b and @WojtekKowaluk promised also to continue with variable files and modifiers.
Have you @WojtekKowaluk already looked at variable files and modifiers? If not, I can easily take care about them today or tomorrow. We try to get alpha 3 ready this week and would like to get this one finished before that.
hello, please go ahead. I don't feel like I am able to complete this in timely manner. I think I will help Stan with detecting unused imports instead or do other task with low priority.
changed the title [-]Allow giving listener, variable file and model modifier instances to `robot.run` and `TestSuite.run`[/-][+]Allow giving listener and model modifier instances to `robot.run` and `TestSuite.run`[/+]on Jun 16, 2015
I decided to drop variable files from the scope of this issue for the following reasons:
Supporting them would have required more changes to variable file import logic. Nothing major but not exactly trivial either.
Nobody has actually asked that functionality.
It would probably be a better idea to allow passing variables as a dict like {'var1': 'value', 'var2': 2} anyway.
A new issue can be submitted if someone wants to make it easier to pass variables to the programmatic APIs. We can then separately decide what is the best way to implement it.
This issue now covers only listeners and model modifiers which are both done.
Activity
pekkaklarck commentedon Apr 13, 2015
Would it be enough that in addition of
you could also do
I know I would have liked the above functionality few times. It shouldn't be too complicated to implement either.
vkruoso commentedon Apr 13, 2015
I'm also interested on a feature like this, but my use case is a little bit different. I've sent an email in the users list: "Add listener instance using robot.api".
The idea is to be able to register a listener instance at any point in robot execution. In my use case it would be in the initialization method of robot's dynamic library (that library works as a proxy).
pekkaklarck commentedon Apr 13, 2015
@vkruoso, libraries can register listeners since RF 2.8.5 (#811). Does that work for you?
vkruoso commentedon Apr 13, 2015
@pekkaklarck, I'm already using that interface. Let me be a little more clear.
So the Proxy library act as a listener. Great. Now, in the init method (could be in any other), I create a bunch of instances. So what I have is something like:
Now my wish was to register each instance as a listener calling a robot API function (and was also hopping it would check for the ROBOT* attributes). It could be a BuiltIn() method/keyword?
register_listenerfor instance.It might be interesting to restrict scope for those instances so it receives only events from the suite they have been registered.
pekkaklarck commentedon Apr 13, 2015
I see. Would it be enough is
ROBOT_LIBRARY_LISTENERcould be a list of listeners? That ought to be pretty easy to implement, but would require listeners to be created in__init__. An API to register listeners at any time would be more flexible and could be used also other code than libraries, but it would need a way to restrict the scope of the listener or/and have a way to unregister a listener. This would also be a new API and thus a bit more work to implement, test and document.@spikergit1, are you also looking for an API to register listeners at any time or would being able to pass a listener instance to
robot.runandTestSuite.runbe enough in your use case?uSpike commentedon Apr 13, 2015
@pekkaklarck being able to pass instances to
robot.runand/orTestSuite.runwould be enough for me, for now. I do see a benefit in "an API to register listeners at any time", and honestly having combed through theListenercode I don't think it'd be too hard to do. I could submit a PR if you're interested.pekkaklarck commentedon Apr 13, 2015
Personally I have had more needs for passing listener objects to
robot.runthan for having an API to register them at run time. I don't see a problem having both of these possibilities, though, andROBOT_LIBRARY_LISTENERcould be enhanced to accept a list of listeners as the third option. I consider these separate enhancements that require their own issues and possible PRs, though.Should we agree that this issue is about passing objects to
robot.runandTestSuite.run, and a new issues are submitted about possible other enhancements? If you agree, please submit issues about enhancements you care about. Please also provide PRs for issues you really care about.vkruoso commentedon Apr 14, 2015
I will open a separate issue to support lists on
ROBOT_LIBRARY_LISTENERand will try to provide a pull request for it.pekkaklarck commentedon Apr 23, 2015
Thanks @vkruoso for submitting #1970 about enhancing
ROBOT_LIBRARY_LISTENERto support lists. This issue is now officially about being able to pass actual listener instances torobot.runandTestSuite.run.We are planning to add support for visitors that can modify test suites before execution in RF 2.9 (#1976). We plan to support something like
--visitor MyVisitorfrom the command line, similarly as with listeners, but also want to be able to pass actual visitor instances torobot.runandTestSuite.run. Same helper probably can handle both listeners and visitors so it makes sense to include also this issue in RF 2.9.[-]Support listener instance registration[/-][+]Allow giving listener instances to `robot.run` and `TestSuite.run`[/+]WojtekKowaluk commentedon May 6, 2015
hey, we are working on this task. we will make pull request tomorrow after code review.
6 remaining items
pekkaklarck commentedon Jun 2, 2015
Now that #1993 that @WojtekKowaluk encountered when implementing this feature is fixed, it's possible to look at this issue again. We already dropped this from alpha 2 because we plan to create it tomorrow, but if we get a good PR adding this back is still possible.
Notice that the PR doesn't need to contain fixes to listeners, variable files and modifiers, just concentrating on listeners is enough. Separate PRs and possible separate issues can then be submitted about others.
WojtekKowaluk commentedon Jun 3, 2015
I have rebased PR on master branch. I think I will leave variable files and modifiers for other PR. I'm waiting for your comments.
Merge pull request #1987 from WojtekKowaluk/pass-listener-instances
pekkaklarck commentedon Jun 10, 2015
PR #1987 implementing the listener part of this issue was merged in 7dd3a9b and @WojtekKowaluk promised also to continue with variable files and modifiers.
pekkaklarck commentedon Jun 15, 2015
Have you @WojtekKowaluk already looked at variable files and modifiers? If not, I can easily take care about them today or tomorrow. We try to get alpha 3 ready this week and would like to get this one finished before that.
WojtekKowaluk commentedon Jun 15, 2015
hello, please go ahead. I don't feel like I am able to complete this in timely manner. I think I will help Stan with detecting unused imports instead or do other task with low priority.
Support passing pre-run/rebot modifiers as instances to robot.run/rebot.
API doc to pass modifiers as instances #1969
pekkaklarck commentedon Jun 15, 2015
Modifiers done. Variable files turned out to be a bit more complicated. Need to think can they handled cleanly without too much work.
[-]Allow giving listener, variable file and model modifier instances to `robot.run` and `TestSuite.run`[/-][+]Allow giving listener and model modifier instances to `robot.run` and `TestSuite.run`[/+]pekkaklarck commentedon Jun 16, 2015
I decided to drop variable files from the scope of this issue for the following reasons:
{'var1': 'value', 'var2': 2}anyway.A new issue can be submitted if someone wants to make it easier to pass variables to the programmatic APIs. We can then separately decide what is the best way to implement it.
This issue now covers only listeners and model modifiers which are both done.