You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
666 B

  1. from contextlib import contextmanager
  2. import wx
  3. from gui import application
  4. from python_bindings.config_generator import create_from_parser
  5. from python_bindings.gooey_decorator import defaults
  6. from util.functional import merge
  7. @contextmanager
  8. def instrumentGooey(parser, **kwargs):
  9. """
  10. Context manager used during testing for setup/tear down of the
  11. WX infrastructure during subTests.
  12. """
  13. buildspec = create_from_parser(parser, "", **merge(defaults, kwargs))
  14. app, gooey = application.build_app(buildspec)
  15. try:
  16. yield (app, gooey)
  17. finally:
  18. wx.CallAfter(app.ExitMainLoop)
  19. gooey.Destroy()
  20. app.Destroy()