|
4 | 4 | import uuid |
5 | 5 | from collections.abc import Iterable, Iterator |
6 | 6 | from http import HTTPStatus |
7 | | -from pathlib import Path |
8 | | -from typing import TYPE_CHECKING, cast |
| 7 | +from typing import TYPE_CHECKING |
9 | 8 |
|
10 | 9 | import docker |
11 | 10 | import pytest |
@@ -53,7 +52,7 @@ def wait_for_health_check(container: Container) -> None: |
53 | 52 | """Wait for a container to pass its health check. |
54 | 53 |
|
55 | 54 | 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. |
57 | 56 | """ |
58 | 57 | try: |
59 | 58 | _poll_health_check(container=container) |
@@ -158,7 +157,7 @@ def test_build_and_run( |
158 | 157 | windows_message_substring in exc.msg |
159 | 158 | for windows_message_substring in windows_message_substrings |
160 | 159 | ): |
161 | | - raise AssertionError(full_log) from exc |
| 160 | + raise AssertionError(full_log) from exc # pragma: no cover |
162 | 161 | pytest.skip( |
163 | 162 | reason="We do not currently support using Windows containers." |
164 | 163 | ) |
@@ -275,62 +274,3 @@ def test_build_and_run( |
275 | 274 | matching_targets = cloud_reco_client.query(image=high_quality_image) |
276 | 275 |
|
277 | 276 | 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