def test_dependencies(monkeypatch):
    """Test that the MPI environment requires the `mpi4py` package."""
    monkeypatch.setattr(lightning.fabric.plugins.environments.mpi, "_MPI4PY_AVAILABLE", False)
    with pytest.raises(ModuleNotFoundError):
        MPIEnvironment()

    # pretend mpi4py is available
    monkeypatch.setattr(lightning.fabric.plugins.environments.mpi, "_MPI4PY_AVAILABLE", True)
    with mock.patch.dict("sys.modules", {"mpi4py": MagicMock()}):
        MPIEnvironment()
Test that the MPI environment requires the `mpi4py` package.
tests/tests_fabric/plugins/environments/test_mpi.py