-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
148 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pytest_plugins = ["pytester"] # pylint: disable=invalid-name | ||
pytest_plugins = ["pytester"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
from typing import Dict | ||
from unittest import mock | ||
|
||
import pytest | ||
from pytest_docker.plugin import get_docker_ip | ||
|
||
|
||
def test_docker_ip_native(): | ||
environ = {} | ||
def test_docker_ip_native() -> None: | ||
environ: Dict[str, str] = {} | ||
with mock.patch("os.environ", environ): | ||
assert get_docker_ip() == "127.0.0.1" | ||
|
||
|
||
def test_docker_ip_remote(): | ||
def test_docker_ip_remote() -> None: | ||
environ = {"DOCKER_HOST": "tcp://1.2.3.4:2376"} | ||
with mock.patch("os.environ", environ): | ||
assert get_docker_ip() == "1.2.3.4" | ||
|
||
|
||
def test_docker_ip_unix(): | ||
def test_docker_ip_unix() -> None: | ||
environ = {"DOCKER_HOST": "unix:///run/user/1000/podman/podman.sock"} | ||
with mock.patch("os.environ", environ): | ||
assert get_docker_ip() == "127.0.0.1" | ||
|
||
|
||
@pytest.mark.parametrize("docker_host", ["http://1.2.3.4:2376"]) | ||
def test_docker_ip_remote_invalid(docker_host): | ||
def test_docker_ip_remote_invalid(docker_host: str) -> None: | ||
environ = {"DOCKER_HOST": docker_host} | ||
with mock.patch("os.environ", environ): | ||
with pytest.raises(ValueError) as exc: | ||
print(get_docker_ip()) | ||
assert str(exc.value) == ( | ||
'Invalid value for DOCKER_HOST: "%s".' % (docker_host,) | ||
) | ||
assert str(exc.value) == ('Invalid value for DOCKER_HOST: "%s".' % (docker_host,)) |
Oops, something went wrong.