Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docker/api/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def create_host_config(self, *args, **kwargs):
bytes) or a string with a units identification char
(``100000b``, ``1000k``, ``128m``, ``1g``). If a string is
specified without a units character, bytes are assumed as an
mem_reservation (int or str): Memory soft limit.
mem_reservation (float or str): Memory soft limit.
mem_swappiness (int): Tune a container's memory swappiness
behavior. Accepts number between 0 and 100.
memswap_limit (str or int): Maximum amount of memory + swap a
Expand Down Expand Up @@ -1219,8 +1219,8 @@ def update_container(
cpu_shares (int): CPU shares (relative weight)
cpuset_cpus (str): CPUs in which to allow execution
cpuset_mems (str): MEMs in which to allow execution
mem_limit (int or str): Memory limit
mem_reservation (int or str): Memory soft limit
mem_limit (float or str): Memory limit
mem_reservation (float or str): Memory soft limit
memswap_limit (int or str): Total memory (memory + swap), -1 to
disable swap
kernel_memory (int or str): Kernel memory limit
Expand Down
2 changes: 1 addition & 1 deletion docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def parse_bytes(s):

if suffix in units.keys() or suffix.isdigit():
try:
digits = int(digits_part)
digits = float(digits_part)
except ValueError:
raise errors.DockerException(
'Failed converting the string value for memory ({0}) to'
Expand Down
24 changes: 7 additions & 17 deletions tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@
import os
import os.path
import shutil
import sys
import tempfile
import unittest


import pytest
import six
from docker.api.client import APIClient
from docker.constants import IS_WINDOWS_PLATFORM
from docker.errors import DockerException
from docker.utils import (
convert_filters, convert_volume_binds, decode_json_header, kwargs_from_env,
parse_bytes, parse_devices, parse_env_file, parse_host,
parse_repository_tag, split_command, update_headers,
)

from docker.utils import (convert_filters, convert_volume_binds,
decode_json_header, kwargs_from_env, parse_bytes,
parse_devices, parse_env_file, parse_host,
parse_repository_tag, split_command, update_headers)
from docker.utils.ports import build_port_bindings, split_port
from docker.utils.utils import format_environment

import pytest

import six

TEST_CERT_DIR = os.path.join(
os.path.dirname(__file__),
'testdata/certs',
Expand Down Expand Up @@ -447,11 +441,7 @@ def test_parse_bytes_invalid(self):
parse_bytes("127.0.0.1K")

def test_parse_bytes_float(self):
with pytest.raises(DockerException):
parse_bytes("1.5k")

def test_parse_bytes_maxint(self):
assert parse_bytes("{0}k".format(sys.maxsize)) == sys.maxsize * 1024
assert parse_bytes("1.5k") == 1536


class UtilsTest(unittest.TestCase):
Expand Down