From 8a25704aaca11f693029c3a5f419b4a61c929cf6 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 23 Mar 2026 04:12:46 -0700 Subject: [PATCH] add harness tests --- archivebox/tests/test_test_harness.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 archivebox/tests/test_test_harness.py diff --git a/archivebox/tests/test_test_harness.py b/archivebox/tests/test_test_harness.py new file mode 100644 index 00000000..686c31a9 --- /dev/null +++ b/archivebox/tests/test_test_harness.py @@ -0,0 +1,29 @@ +import os +from pathlib import Path + +import pytest + +from archivebox.tests import conftest as test_harness + + +def test_session_data_dir_is_outside_repo_root(): + assert test_harness.SESSION_DATA_DIR != test_harness.REPO_ROOT + assert test_harness.REPO_ROOT not in test_harness.SESSION_DATA_DIR.parents + assert test_harness.REPO_ROOT not in Path.cwd().parents + assert Path.cwd() != test_harness.REPO_ROOT + + +def test_cli_helpers_reject_repo_root_runtime_paths(): + with pytest.raises(AssertionError, match="repo root"): + test_harness.run_archivebox_cmd(["version"], data_dir=test_harness.REPO_ROOT) + + with pytest.raises(AssertionError, match="repo root"): + test_harness.run_archivebox_cmd_cwd(["version"], cwd=test_harness.REPO_ROOT) + + with pytest.raises(AssertionError, match="repo root"): + test_harness.run_python_cwd("print('hello')", cwd=test_harness.REPO_ROOT) + + +def test_runtime_guard_rejects_chdir_into_repo_root(): + with pytest.raises(AssertionError, match="repo root"): + os.chdir(test_harness.REPO_ROOT)