class_docstr: Tests various failure-modes, making sure we produce meaningful errmsgs.
docstr: Tests different "bad env" errors.
code: def test_bad_envs(self):
      """Tests different "bad env" errors."""
      config = (
          ppo.PPOConfig().rollouts(num_rollout_workers=0)
          # Non existing/non-registered gym env string.
          .environment("Alien-Attack-v42")
      )
  
      for _ in framework_iterator(config):
          self.assertRaisesRegex(
              EnvError,
              f"The env string you provided \\('{config.env}'\\) is",
              lambda: config.build(),
          )
  
      # Malformed gym env string (must have v\d at end).
      config.environment("Alien-Attack-part-42")
      for _ in framework_iterator(config):
          self.assertRaisesRegex(
              EnvError,
              f"The env string you provided \\('{config.env}'\\) is",
              lambda: config.build(),
          )
  
      # Non-existing class in a full-class-path.
      config.environment(
          "ray.rllib.examples.env.random_env.RandomEnvThatDoesntExist"
      )
      for _ in framework_iterator(config):
          self.assertRaisesRegex(
              EnvError,
              f"The env string you provided \\('{config.env}'\\) is",
              lambda: config.build(),
          )
  
      # Non-existing module inside a full-class-path.
      config.environment(
          "ray.rllib.examples.env.module_that_doesnt_exist.SomeEnv"
      )
      for _ in framework_iterator(config):
          self.assertRaisesRegex(
              EnvError,
              f"The env string you provided \\('{config.env}'\\) is",
              lambda: config.build(),
          )
  
file_path: ray/rllib/utils/tests/test_errors.py
imports: import unittest
  import ray
  import ray.rllib.algorithms.impala
  import ray.rllib.algorithms.ppo
  from ray.rllib.utils.error import EnvError
  from ray.rllib.utils.test_utils import framework_iterator
label_desc: Use image node_id 4 for calling the TestErrors obj's underlying member method code with example usage: obj.test_bad_envs() without return types