Skip to content

Listeners are not unregistered when using TestSuite.run API #1992

Closed

Description

@WojtekKowaluk

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.

Activity

  1. WojtekKowaluk commented on May 13, 2015

    @WojtekKowaluk
    ContributorAuthor

    Seems this fixes the problem:
    #1993

  2. added this to the 2.9 milestone on May 13, 2015
  3. pekkaklarck commented on May 13, 2015

    @pekkaklarck
    Member

    Have you tested does this happen also with robot.run API or only with TestSuite.run?

  4. WojtekKowaluk commented on May 13, 2015

    @WojtekKowaluk
    ContributorAuthor

    I will check that.

  5. WojtekKowaluk commented on May 13, 2015

    @WojtekKowaluk
    ContributorAuthor

    I have tried and this does not happen with robot.run.

  6. pekkaklarck commented on May 13, 2015

    @pekkaklarck
    Member

    Interesting. Have you analyzed why not?

  7. WojtekKowaluk commented on May 14, 2015

    @WojtekKowaluk
    ContributorAuthor

    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.

  8. WojtekKowaluk commented on May 21, 2015

    @WojtekKowaluk
    ContributorAuthor

    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.

  9. pekkaklarck commented on May 21, 2015

    @pekkaklarck
    Member

    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.

  10. WojtekKowaluk commented on May 21, 2015

    @WojtekKowaluk
    ContributorAuthor

    It is already done: #1993
    Or do you mean we need something more?

  11. pekkaklarck commented on May 21, 2015

    @pekkaklarck
    Member

    Sorry, forgot about that. Hopefully I have time to look at it and some other PRs tomorrow.

  12. 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
  13. pekkaklarck commented on Jun 2, 2015

    @pekkaklarck
    Member

    PR #1993 was merged in 0886b61. This issue can be considered done. Thanks @WojtekKowaluk!!

  14. pekkaklarck commented on Jun 2, 2015

    @pekkaklarck
    Member

    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.

  15. WojtekKowaluk commented on Jun 2, 2015

    @WojtekKowaluk
    ContributorAuthor

    I'm sorry to hear that. :(

  16. pekkaklarck commented on Jun 2, 2015

    @pekkaklarck
    Member

    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.

  17. pekkaklarck commented on Jun 2, 2015

    @pekkaklarck
    Member

    Fixed by a4c4ae1.

  18. self-assigned this
    on Jun 4, 2015
  19. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions