#NEWLINE# @ contextlib . contextmanager #NEWLINE# def delete_widget( self , widget , timeout = 1.0 ) : #NEWLINE# #INDENT# 'Runs the real Qt event loop until the widget provided has been\n        deleted.\n\n        Parameters\n        ----------\n        widget : QObject\n            The widget whose deletion will stop the event loop.\n        timeout : float\n            Number of seconds to run the event loop in the case that the\n            widget is not deleted.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# with self . event_loop_helper . delete_widget ( widget , timeout = timeout ) : #NEWLINE# #INDENT# ( yield ) #NEWLINE# #UNINDENT# #UNINDENT# except ConditionTimeoutError : #NEWLINE# #INDENT# self . fail ( 'Could not destroy widget before timeout: {!r}' . format ( widget ) )