From 8b1c9ff1842d380b7cb0f50319a269f287f066f4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 11:45:36 +0100 Subject: [PATCH] Fail the scratch copy's test on a socket, not a patched function --- bin/task_bench/test_scratch_copy.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/task_bench/test_scratch_copy.py b/bin/task_bench/test_scratch_copy.py index f5524866..6580dcad 100644 --- a/bin/task_bench/test_scratch_copy.py +++ b/bin/task_bench/test_scratch_copy.py @@ -1,10 +1,10 @@ """The copy of a tree that a mutation tool runs in.""" import os import pathlib +import socket import sys import tempfile import unittest -import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) @@ -40,11 +40,14 @@ class ScratchCopyTest(unittest.TestCase): self.assertTrue(os.path.isdir(os.path.join(copy, "src", os.path.basename(first)))) def test_fails_without_a_scratch_folder_left_where_the_tree_cannot_be_copied(self): - with unittest.mock.patch("shutil.copytree", side_effect=OSError("No space left on device")): - found = scratch_copy(str(self.top)) + # A socket is an entry that no copy can read. + held = socket.socket(socket.AF_UNIX) + self.addCleanup(held.close) + held.bind(str(self.top / "held")) + found = scratch_copy(str(self.top)) self.assertIsInstance(found, Failure) - self.assertRegex(found.reason, rf"^could not copy {self.top} into {self.top}/\.mutate-changes-[^/]+: No space left on device$") - self.assertEqual(sorted(path.name for path in self.top.iterdir()), [".hidden", "src"]) + self.assertRegex(found.reason, rf"^could not copy {self.top} into {self.top}/\.mutate-changes-[^/]+: ") + self.assertEqual(sorted(path.name for path in self.top.iterdir()), [".hidden", "held", "src"]) def test_passes_on_that_no_scratch_folder_could_be_made(self): found = scratch_copy(str(self.top / "missing"))