mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 03:46:55 +00:00
Fix/improve unit tests (#1281)
* Fix conditional import. * Don't count lines for code coverage which should never execute. * Fix tests to use pytest.raises.
This commit is contained in:
@@ -21,11 +21,13 @@ from ..test_support.docker_image_archive_stubbing import (
|
||||
)
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable # pragma: no cover
|
||||
|
||||
|
||||
def assert_no_logging(msg: str) -> t.NoReturn:
|
||||
raise AssertionError(f"Should not have logged anything but logged {msg}")
|
||||
raise AssertionError(
|
||||
f"Should not have logged anything but logged {msg}"
|
||||
) # pragma: no cover
|
||||
|
||||
|
||||
def capture_logging(messages: list[str]) -> Callable[[str], None]:
|
||||
|
||||
@@ -12,7 +12,8 @@ from ansible_collections.community.docker.plugins.modules import (
|
||||
docker_swarm_service,
|
||||
)
|
||||
|
||||
APIError = pytest.importorskip("docker.errors.APIError")
|
||||
docker_errors = pytest.importorskip("docker.errors")
|
||||
APIError = docker_errors.APIError
|
||||
|
||||
|
||||
def test_retry_on_out_of_sequence_error(mocker: t.Any) -> None:
|
||||
|
||||
Reference in New Issue
Block a user