tests: don't leak files/descriptors when tests finish (#9119)

close open files/descriptors when tests finish
This commit is contained in:
skshetry
2023-03-06 18:06:37 +05:45
committed by GitHub
parent c5a3566e49
commit ddfa607437
2 changed files with 7 additions and 3 deletions
+5 -2
View File
@@ -23,14 +23,17 @@ def mock_popen(mocker):
["/bin/foo", "-o", "option"],
],
)
def test_init_args(tmp_dir, args, mocker):
def test_init_args(tmp_dir, request, args, mocker):
expected = ["/bin/foo", "-o", "option"]
proc = ManagedProcess(args)
request.addfinalizer(proc._close_fds)
assert expected == proc.args
def test_run(tmp_dir, mocker):
def test_run(tmp_dir, request, mocker):
proc = ManagedProcess("/bin/foo")
request.addfinalizer(proc._close_fds)
assert proc.pid == TEST_PID
with open(proc.info_path, encoding="utf-8") as fobj: