File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 11from .api .client import APIClient
2+ from .constants import DEFAULT_TIMEOUT_SECONDS
23from .models .containers import ContainerCollection
34from .models .images import ImageCollection
45from .models .networks import NetworkCollection
@@ -73,7 +74,7 @@ def from_env(cls, **kwargs):
7374 .. _`SSL version`:
7475 https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1
7576 """
76- timeout = kwargs .pop ('timeout' , None )
77+ timeout = kwargs .pop ('timeout' , DEFAULT_TIMEOUT_SECONDS )
7778 version = kwargs .pop ('version' , None )
7879 return cls (timeout = timeout , version = version ,
7980 ** kwargs_from_env (** kwargs ))
Original file line number Diff line number Diff line change 11import datetime
22import docker
33from docker .utils import kwargs_from_env
4+ from docker .constants import (
5+ DEFAULT_DOCKER_API_VERSION , DEFAULT_TIMEOUT_SECONDS
6+ )
47import os
58import unittest
69
@@ -96,3 +99,13 @@ def test_from_env_with_version(self):
9699 client = docker .from_env (version = '2.32' )
97100 self .assertEqual (client .api .base_url , "https://192.168.59.103:2376" )
98101 self .assertEqual (client .api ._version , '2.32' )
102+
103+ def test_from_env_without_version_uses_default (self ):
104+ client = docker .from_env ()
105+
106+ self .assertEqual (client .api ._version , DEFAULT_DOCKER_API_VERSION )
107+
108+ def test_from_env_without_timeout_uses_default (self ):
109+ client = docker .from_env ()
110+
111+ self .assertEqual (client .api .timeout , DEFAULT_TIMEOUT_SECONDS )
You can’t perform that action at this time.
0 commit comments