def test_reinit_crypto_on_fork(def_mock):
    """
    Ensure salt.utils.crypt.reinit_crypto() is executed when forking for new job
    """
    mock_opts = salt.config.DEFAULT_MINION_OPTS.copy()
    mock_opts["multiprocessing"] = True

    io_loop = salt.ext.tornado.ioloop.IOLoop()
    io_loop.make_current()
    minion = salt.minion.Minion(mock_opts, io_loop=io_loop)

    job_data = {"jid": "test-jid", "fun": "test.ping"}

    def mock_start(self):
        # pylint: disable=comparison-with-callable
        assert (
            len(
                [
                    x
                    for x in self._after_fork_methods
                    if x[0] == salt.utils.crypt.reinit_crypto
                ]
            )
            == 1
        )
        # pylint: enable=comparison-with-callable

    with patch.object(salt.utils.process.SignalHandlingProcess, "start", mock_start):
        io_loop.run_sync(lambda: minion._handle_decoded_payload(job_data))