From a62858f89d42a2fcd5631dd8b8e8fbfa13b07cc4 Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Tue, 19 Apr 2022 13:01:03 -0700 Subject: [PATCH] Ensure python doc tests failures will fail health-check. And fix a nit in the existing tests to make it pass. BUG=b:219965702 TEST=presubmit Change-Id: I65fb98b04d7042755930dd34913f679fa129c88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3594248 Reviewed-by: Maciek Swiech Tested-by: kokoro --- tools/health-check | 5 +++-- tools/impl/common.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/health-check b/tools/health-check index 284ffa781e..cd77f4924f 100755 --- a/tools/health-check +++ b/tools/health-check @@ -17,8 +17,9 @@ def check_python(): print("Running python doctests") for source in Path("tools/impl").glob("*.py"): lib = importlib.import_module(f"impl.{source.stem}") - doctest.testmod(lib, optionflags=doctest.ELLIPSIS) - + result = doctest.testmod(lib, optionflags=doctest.ELLIPSIS) + if result.failed: + sys.exit(1) print("Type-checking python") parallel( mypy("tools/impl"), diff --git a/tools/impl/common.py b/tools/impl/common.py index 0fe2fcc4d3..89462583d1 100644 --- a/tools/impl/common.py +++ b/tools/impl/common.py @@ -451,7 +451,7 @@ def batched(source: Iterable[T], max_batch_size: int) -> Iterable[list[T]]: """ Returns an iterator over batches of elements from source_list. - >>> list(batched([1, 2, 3, 4, 5], batch_size=2)) + >>> list(batched([1, 2, 3, 4, 5], 2)) [[1, 2], [3, 4], [5]] """ source_list = list(source)