code: def test_invalid_environment(monkeypatch, env_fixture_0):
      """Test that initializing an Experiment when there is an active `Environment` -- but
      :attr:`hyperparameter_hunter.environment.Environment.current_task` is not None -- raises
      `EnvironmentInvalidError`"""
      # Currently have a valid `settings.G.Env` (`env_fixture_0`), so give it a fake `current_task`
      monkeypatch.setattr(
          settings.G.Env, "current_task", "some other task"
      )
      with pytest.raises(
          EnvironmentInvalidError,
          match="Current experiment must finish before .*",
      ):
          CVExperiment(LogisticRegression, dict())
  
file_path: hyperparameter_hunter/tests/test_experiments.py
imports: from hyperparameter_hunter import settings
  from hyperparameter_hunter.experiments import BaseExperiment, CVExperiment, get_cv_indices
  from hyperparameter_hunter.i_o.exceptions import EnvironmentInactiveError, EnvironmentInvalidError
  import numpy
  from numpy.testing import assert_equal
  import pytest
  from sklearn.linear_model import LogisticRegression
  from sklearn.model_selection import KFold, RepeatedKFold
label_desc: Use image node_id 2 for calling a global function with example usage: test_invalid_environment(monkeypatch, env_fixture_0) without return types