Fail the scratch copy's test on a socket, not a patched function
CI / tests (pull_request) Successful in 8m49s
CI / tests (pull_request) Successful in 8m49s
This commit is contained in:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user