File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import os
33import shutil
44import subprocess
5+ import time
56import unittest
67from glob import glob
78from unittest .mock import Mock , patch
@@ -346,6 +347,20 @@ def test_terminate_multiple_calls(self):
346347 self .mock_process .terminate .assert_called_once () # Only called on first invocation
347348 self .mock_logger .warning .assert_called_once_with ("The process was already done!" )
348349
350+ @patch ("custodian.vasp.jobs.VaspJob.__init__" , return_value = None )
351+ def test_terminate_integration_with_real_process (self , mock_init ):
352+ """Test termination with a real subprocess (integration-style test)."""
353+ # Arrange
354+ vasp_job = VaspJob .__new__ (VaspJob ) # Create instance without calling __init__
355+
356+ real_process = subprocess .Popen (["sleep" , "10" ])
357+ vasp_job ._vasp_process = real_process
358+
359+ with patch ("custodian.vasp.jobs.logger" ) as mock_logger :
360+ vasp_job .terminate ()
361+ assert real_process .poll () is not None # Process should be terminated
362+ mock_logger .info .assert_called_once ()
363+
349364
350365class TestVaspJobTerminateEdgeCases (unittest .TestCase ):
351366 """Additional edge case tests for VaspJob.terminate()."""
You can’t perform that action at this time.
0 commit comments