diff --git a/tests/conftest.py b/tests/conftest.py index af29c211db4..c8134083b95 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -123,7 +123,9 @@ def fixture_copy_case(tmp_path_factory, source_root, monkeypatch): def _copy_case(path): tmp_path = tmp_path_factory.mktemp(path.replace("/", "-")) shutil.copytree( - os.path.join(source_root, "test-data", path), tmp_path / "test_data" + os.path.join(source_root, "test-data", path), + tmp_path / "test_data", + ignore=shutil.ignore_patterns("storage"), ) monkeypatch.chdir(tmp_path / "test_data") diff --git a/tests/unit_tests/cli/test_integration_cli.py b/tests/unit_tests/cli/test_integration_cli.py index 4c8948d3312..03527a472cb 100644 --- a/tests/unit_tests/cli/test_integration_cli.py +++ b/tests/unit_tests/cli/test_integration_cli.py @@ -174,15 +174,14 @@ def test_cli_does_not_run_without_observations(tmpdir, source_root, mode, target os.path.join(str(tmpdir), "poly_example"), ) - def remove_line(file_name, line_num): - with open(file_name, "r", encoding="utf-8") as f: - lines = f.readlines() - with open(file_name, "w", encoding="utf-8") as f: - f.writelines(lines[: line_num - 1] + lines[line_num:]) + def remove_linestartswith(file_name: str, startswith: str): + lines = Path(file_name).read_text(encoding="utf-8").split("\n") + lines = [line for line in lines if not line.startswith(startswith)] + Path(file_name).write_text("\n".join(lines), encoding="utf-8") with tmpdir.as_cwd(): # Remove observations from config file - remove_line("poly_example/poly.ert", 8) + remove_linestartswith("poly_example/poly.ert", "OBS_CONFIG") parser = ArgumentParser(prog="test_main") parsed = ert_parser(