code: def test_srun_variable_validation():
      """Test that we raise useful errors when `srun` variables are misconfigured."""
      with mock.patch.dict(os.environ, {"SLURM_NTASKS": "1"}):
          SLURMEnvironment()
      with mock.patch.dict(
          os.environ, {"SLURM_NTASKS": "2"}
      ), pytest.raises(
          RuntimeError, match="You set `--ntasks=2` in your SLURM"
      ):
          SLURMEnvironment()
  
file_path: pytorch-lightning/tests/tests_fabric/plugins/environments/test_slurm.py
imports: import logging
  import os
  import shutil
  import sys
  from unittest import mock
  import pytest
  from lightning.fabric.plugins.environments import SLURMEnvironment
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning_utilities.test.warning import no_warning_call
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 7 for calling a global function with example usage: test_srun_variable_validation() without return types