mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
tests: don't leak files/descriptors when tests finish (#9119)
close open files/descriptors when tests finish
This commit is contained in:
@@ -15,7 +15,7 @@ def test_with(tmp_dir, dvc, mocker):
|
||||
pass
|
||||
|
||||
|
||||
def test_unlock_lock_failed(tmp_dir, dvc, mocker):
|
||||
def test_unlock_lock_failed(tmp_dir, dvc, request, mocker):
|
||||
# patching to speedup tests
|
||||
mocker.patch("dvc.lock.DEFAULT_TIMEOUT", 0.01)
|
||||
|
||||
@@ -28,6 +28,7 @@ def test_unlock_lock_failed(tmp_dir, dvc, mocker):
|
||||
with lock:
|
||||
lock.unlock()
|
||||
lock_ext.lock() # imitate an exernal process had time to lock it
|
||||
request.addfinalizer(lock_ext.unlock)
|
||||
with pytest.raises(LockError):
|
||||
lock.lock()
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user