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 <drmasquatch@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Dennis Kempin 2022-04-19 13:01:03 -07:00
parent 25d7911e8d
commit a62858f89d
2 changed files with 4 additions and 3 deletions

View file

@ -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"),

View file

@ -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)