def test_load_data_context_from_environment_variables(tmp_path_factory): try: project_path = str(tmp_path_factory.mktemp('data_context')) context_path = os.path.join(project_path, "great_expectations") safe_mmkdir(context_path) shutil.copy("./tests/test_fixtures/great_expectations_basic.yml", str(os.path.join(context_path, "great_expectations.yml"))) with pytest.raises(DataContextError) as err: DataContext.find_context_root_dir() assert "Unable to locate context root directory." in err os.environ["GE_HOME"] = context_path assert DataContext.find_context_root_dir() == context_path except Exception: raise finally: # Make sure we unset the environment variable we're using del os.environ["GE_HOME"]
def test_load_data_context_from_environment_variables(tmp_path_factory): curdir = os.path.abspath(os.getcwd()) try: project_path = str(tmp_path_factory.mktemp('data_context')) context_path = os.path.join(project_path, "great_expectations") safe_mmkdir(context_path) os.chdir(context_path) with pytest.raises(DataContextError) as err: DataContext.find_context_root_dir() assert isinstance(err.value, ConfigNotFoundError) shutil.copy(file_relative_path(__file__, "../test_fixtures/great_expectations_basic.yml"), str(os.path.join(context_path, "great_expectations.yml"))) os.environ["GE_HOME"] = context_path assert DataContext.find_context_root_dir() == context_path except Exception: raise finally: # Make sure we unset the environment variable we're using if "GE_HOME" in os.environ: del os.environ["GE_HOME"] os.chdir(curdir)