File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,8 @@ def get_docker_ip() -> Union[str, Any]:
46
46
if not docker_host or docker_host .startswith ("unix://" ):
47
47
return "127.0.0.1"
48
48
49
- match = re .match (r"^tcp://(.+?):\d+$" , docker_host )
50
- if not match :
51
- raise ValueError ('Invalid value for DOCKER_HOST: "%s".' % (docker_host ,))
52
- return match .group (1 )
49
+ # Return just plain address without prefix and port
50
+ return re .sub (r"^[^:]+://(.+):\d+$" , r"\1" , docker_host )
53
51
54
52
55
53
@pytest .fixture (scope = containers_scope )
Original file line number Diff line number Diff line change @@ -23,10 +23,8 @@ def test_docker_ip_unix() -> None:
23
23
assert get_docker_ip () == "127.0.0.1"
24
24
25
25
26
- @pytest .mark .parametrize ("docker_host" , ["http://1.2.3.4:2376" ])
26
+ @pytest .mark .parametrize ("docker_host" , ["http://1.2.3.4:2376" , "tcp://1.2.3.4:2376" ])
27
27
def test_docker_ip_remote_invalid (docker_host : str ) -> None :
28
28
environ = {"DOCKER_HOST" : docker_host }
29
29
with mock .patch ("os.environ" , environ ):
30
- with pytest .raises (ValueError ) as exc :
31
- print (get_docker_ip ())
32
- assert str (exc .value ) == ('Invalid value for DOCKER_HOST: "%s".' % (docker_host ,))
30
+ assert get_docker_ip () == "1.2.3.4"
You can’t perform that action at this time.
0 commit comments