def test_detect():
    """Test the detection of a SLURM environment configuration."""
    with mock.patch.dict(os.environ, {}, clear=True):
        assert not SLURMEnvironment.detect()

    with mock.patch.dict(os.environ, {"SLURM_NTASKS": "2"}):
        assert SLURMEnvironment.detect()

    with mock.patch.dict(os.environ, {"SLURM_JOB_NAME": "bash"}):
        assert not SLURMEnvironment.detect()

    with mock.patch.dict(os.environ, {"SLURM_JOB_NAME": "interactive"}):
        assert not SLURMEnvironment.detect()
Test the detection of a SLURM environment configuration.
tests/tests_fabric/plugins/environments/test_slurm.py