Skip to content

Commit 32cbfaa

Browse files
Add an integration test
1 parent 332e070 commit 32cbfaa

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/vasp/test_jobs.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import shutil
44
import subprocess
5+
import time
56
import unittest
67
from glob import glob
78
from 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

350365
class TestVaspJobTerminateEdgeCases(unittest.TestCase):
351366
"""Additional edge case tests for VaspJob.terminate()."""

0 commit comments

Comments
 (0)