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
Listeners are not unregistered when using TestSuite.run API #1992
let a and b be instances of TestSuite.
If i run a.run(listeners='listener.py') and then after i run b.run() then listener will still be used during execution of TestSuite b.
With just looking at code I was not able to figure that out. Maybe tomorrow I will add some debug print statements here and there and see if that will help me.
I found the reason.
When I call robot.run, execute method use _logging contextmanager. This manager calls close method on logger object. This method clears self._loggers in logger object. When using TestSuite.run none of that is called. However in both cases close method for listener is never called.
Anyway I think I am on the track with my fix to unregister listeners in close method for output object. Let me know what do you think.
Great that you found the root cause! Your fix sounds good too. It would great if you could create a PR with unit tests and your fix. I can then review it and look at the related code too.
changed the title [-]when using TestSuite.run with listeners, listeners are not unregistered[/-][+]Listeners are not unregistered when using `TestSuite.run` API[/+]on Jun 2, 2015
Unfortunately the fix in PR #1993 broke listener interface slightly. Now that listeners are closed already after execution has ended, they do not get notification when log and report are created. There are tests that catch this error but unfortunately our CI has been down lately and the PR wasn't automatically tested.
Good news is that I have a new fix that looks promising. The idea is to use LOGGER as a context manager so that it can be nested, and automatically call LOGGER.close() when the context manager on top exits.
No worries. This definitely wasn't easy to spot from the code. Obviously it would have been a good idea for you to run all tests on your machine too, but the real problem was that CI was down. Anyway, all tests are now passing on my machine.
Activity
WojtekKowaluk commentedon May 13, 2015
Seems this fixes the problem:
#1993
pekkaklarck commentedon May 13, 2015
Have you tested does this happen also with
robot.runAPI or only withTestSuite.run?WojtekKowaluk commentedon May 13, 2015
I will check that.
WojtekKowaluk commentedon May 13, 2015
I have tried and this does not happen with
robot.run.pekkaklarck commentedon May 13, 2015
Interesting. Have you analyzed why not?
WojtekKowaluk commentedon May 14, 2015
With just looking at code I was not able to figure that out. Maybe tomorrow I will add some debug print statements here and there and see if that will help me.
WojtekKowaluk commentedon May 21, 2015
I found the reason.
When I call
robot.run,executemethod use_loggingcontextmanager. This manager callsclosemethod on logger object. This method clearsself._loggersin logger object. When usingTestSuite.runnone of that is called. However in both casesclosemethod for listener is never called.Anyway I think I am on the track with my fix to unregister listeners in
closemethod for output object. Let me know what do you think.pekkaklarck commentedon May 21, 2015
Great that you found the root cause! Your fix sounds good too. It would great if you could create a PR with unit tests and your fix. I can then review it and look at the related code too.
WojtekKowaluk commentedon May 21, 2015
It is already done: #1993
Or do you mean we need something more?
pekkaklarck commentedon May 21, 2015
Sorry, forgot about that. Hopefully I have time to look at it and some other PRs tomorrow.
[-]when using TestSuite.run with listeners, listeners are not unregistered[/-][+]Listeners are not unregistered when using `TestSuite.run` API[/+]pekkaklarck commentedon Jun 2, 2015
PR #1993 was merged in 0886b61. This issue can be considered done. Thanks @WojtekKowaluk!!
Output.close: Clear list of loggers after unregistering them.
pekkaklarck commentedon Jun 2, 2015
Unfortunately the fix in PR #1993 broke listener interface slightly. Now that listeners are closed already after execution has ended, they do not get notification when log and report are created. There are tests that catch this error but unfortunately our CI has been down lately and the PR wasn't automatically tested.
Good news is that I have a new fix that looks promising. The idea is to use
LOGGERas a context manager so that it can be nested, and automatically callLOGGER.close()when the context manager on top exits.WojtekKowaluk commentedon Jun 2, 2015
I'm sorry to hear that. :(
pekkaklarck commentedon Jun 2, 2015
No worries. This definitely wasn't easy to spot from the code. Obviously it would have been a good idea for you to run all tests on your machine too, but the real problem was that CI was down. Anyway, all tests are now passing on my machine.
Fixed listeners not getting notification about log and report being r…
pekkaklarck commentedon Jun 2, 2015
Fixed by a4c4ae1.