Add functions for checking if a spy was called only once.
Review Request #14621 — Created Sept. 19, 2025 and submitted
A common pattern when using kgb is to check if a spy was called only
once, and sometimes once with specific arguments. Callers had to do this
by checking the call count and then checking the arguments, or to use a
spy operation that would fail if executed more than once.This introduce two new functions to perform these checks in a simpler
manner:
assertSpyCalledOnce()
assertSpyCalledOnceWith()
There are also pytest equivalent functions for both.
All unit tests pass on all environments.
- Change Summary:
-
- Fixed the docstring and variable name in
assertSpyCalledOnceWith
to only take a spy or function, not a call. - Fixed docstrings for several functions to say "Positional" instead of "Position" for arguments.
- Fixed the docstring and variable name in
- Commits:
-
Summary ID 8e621c79fdc1fc6ed956e4570ed6e630748045c4 d76767489b23045696d1a5edeec6ffd315b02f6f - Diff:
-
Revision 2 (+426 -6)
Checks run (2 succeeded)
flake8
passed.
JSHint
passed.