mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Add unit test around linebuffering in binary mode
This commit is contained in:
parent
d33366d9ae
commit
637ded8741
1 changed files with 12 additions and 1 deletions
|
@ -4,12 +4,13 @@ Unit Tests for functions located in salt/utils/files.py
|
|||
|
||||
|
||||
import copy
|
||||
import io
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.utils.files
|
||||
from tests.support.mock import patch
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
|
||||
def test_safe_rm():
|
||||
|
@ -75,6 +76,16 @@ def test_fopen_with_disallowed_fds():
|
|||
)
|
||||
|
||||
|
||||
def test_fopen_binary_line_buffering(tmp_path):
|
||||
tmp_file = os.path.join(tmp_path, "foobar")
|
||||
with patch("builtins.open") as open_mock, patch(
|
||||
"salt.utils.files.is_fcntl_available", MagicMock(return_value=False)
|
||||
):
|
||||
salt.utils.files.fopen(os.path.join(tmp_path, "foobar"), mode="b", buffering=1)
|
||||
assert open_mock.called
|
||||
assert open_mock.call_args[1]["buffering"] == io.DEFAULT_BUFFER_SIZE
|
||||
|
||||
|
||||
def _create_temp_structure(temp_directory, structure):
|
||||
for folder, files in structure.items():
|
||||
current_directory = os.path.join(temp_directory, folder)
|
||||
|
|
Loading…
Add table
Reference in a new issue