Example #1
0
def test_register_when_ui_available(mock_hdefereval):
    """Register the _emit_ui_available function with hdefereval."""
    callbacks._register_when_ui_available()

    # Ensure we passed the _emit_ui_available method to the exec function.
    mock_hdefereval.executeDeferredAfterWaiting.assert_called_once_with(
        callbacks._emit_ui_available, 1)
    def test(self):
        """Register the _emit_ui_available function with hdefereval."""
        mock_hdefereval = MagicMock()

        # Need to mock importing hdefereval because the import will fail when
        # the UI is not available (like in testing).
        modules = {"hdefereval": mock_hdefereval}

        with patch.dict("sys.modules", modules):
            callbacks._register_when_ui_available()

            # Ensure we passed the _emit_ui_available method to the exec function.
            mock_hdefereval.executeDeferredAfterWaiting.assert_called_once_with(callbacks._emit_ui_available, 1)
def test_register_when_ui_available(mocker):
    """Register the _emit_ui_available function with hdefereval."""
    mock_hdefereval = mocker.MagicMock()

    # Need to mock importing hdefereval because the import will fail when
    # the UI is not available (like in testing).
    modules = {"hdefereval": mock_hdefereval}

    mocker.patch.dict("sys.modules", modules)
    callbacks._register_when_ui_available()

    # Ensure we passed the _emit_ui_available method to the exec function.
    mock_hdefereval.executeDeferredAfterWaiting.assert_called_once_with(
        callbacks._emit_ui_available, 1)