Skip to content

Commit ab499ff

Browse files
committed
Use pragma for uncovered Docker branch
1 parent 6e6a7ae commit ab499ff

1 file changed

Lines changed: 3 additions & 63 deletions

File tree

tests/mock_vws/test_docker.py

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import uuid
55
from collections.abc import Iterable, Iterator
66
from http import HTTPStatus
7-
from pathlib import Path
8-
from typing import TYPE_CHECKING, cast
7+
from typing import TYPE_CHECKING
98

109
import docker
1110
import pytest
@@ -53,7 +52,7 @@ def wait_for_health_check(container: Container) -> None:
5352
"""Wait for a container to pass its health check.
5453
5554
On failure, augment the error with the container's logs and the
56-
Docker health check probe history so CI failures are easy to diagnose.
55+
Docker health check probe history so CI failures are diagnosable.
5756
"""
5857
try:
5958
_poll_health_check(container=container)
@@ -158,7 +157,7 @@ def test_build_and_run(
158157
windows_message_substring in exc.msg
159158
for windows_message_substring in windows_message_substrings
160159
):
161-
raise AssertionError(full_log) from exc
160+
raise AssertionError(full_log) from exc # pragma: no cover
162161
pytest.skip(
163162
reason="We do not currently support using Windows containers."
164163
)
@@ -275,62 +274,3 @@ def test_build_and_run(
275274
matching_targets = cloud_reco_client.query(image=high_quality_image)
276275

277276
assert matching_targets[0].target_id == target_id
278-
279-
280-
def test_build_and_run_raises_full_log_for_unexpected_build_error(
281-
*,
282-
monkeypatch: pytest.MonkeyPatch,
283-
tmp_path: Path,
284-
) -> None:
285-
"""An unexpected Docker build error includes the full build log."""
286-
287-
class Images:
288-
"""Mock Docker images API."""
289-
290-
@staticmethod
291-
def build(**_: object) -> tuple[object, object]:
292-
"""Raise an unexpected Docker build error."""
293-
build_log = [
294-
{"stream": "first build log line"},
295-
{"stream": "second build log line"},
296-
{"aux": "ignored"},
297-
]
298-
raise BuildError(
299-
reason="unexpected build failure",
300-
build_log=iter(build_log),
301-
)
302-
303-
class Client:
304-
"""Mock Docker client."""
305-
306-
images = Images()
307-
308-
class Config:
309-
"""Mock pytest config."""
310-
311-
rootpath = tmp_path
312-
313-
class Request:
314-
"""Mock pytest request."""
315-
316-
config = Config()
317-
318-
class CustomBridgeNetwork:
319-
"""Mock Docker network."""
320-
321-
name = "custom-bridge-network"
322-
323-
monkeypatch.setattr(target=docker, name="from_env", value=Client)
324-
325-
with pytest.raises(
326-
expected_exception=AssertionError,
327-
match="first build log line\nsecond build log line",
328-
):
329-
test_build_and_run(
330-
high_quality_image=io.BytesIO(),
331-
custom_bridge_network=cast(
332-
"Network",
333-
CustomBridgeNetwork(),
334-
),
335-
request=cast("pytest.FixtureRequest", Request()),
336-
)

0 commit comments

Comments
 (0)