Add new assertion methods for checking spies.

Review Request #10988 — Created April 4, 2020 and submitted

Information

kgb
master

Reviewers

kgb

KGB is hitting 5.0, and for the first time, it's getting its own
assertion methods.

These are designed to replace the usage of assertTrue, assertEqual,
etc. with checks on a spy or call. They perform the necessary checks and
then provide detailed information if the assertion goes wrong.

The following assertion methods are implemented:

  • assertHasSpy
  • assertSpyCalled
  • assertSpyNotCalled
  • assertSpyCallCount
  • assertSpyCalledWith
  • assertSpyLastCalledWith
  • assertSpyReturned
  • assertSpyLastReturned
  • assertSpyRaised
  • assertSpyLastRaised
  • assertSpyRaisedMessage
  • assertSpyLastRaisedMessage

New code should use these assertion methods for best results.

The README has been updated to show both the new-style and old-style
assertions.

Unit tests pass on all supported versions of Python.

Tested several of these through an update to an existing codebase.

Summary ID
Add new assertion methods for checking spies.
KGB is hitting 5.0, and for the first time, it's getting its own assertion methods. These are designed to replace the usage of `assertTrue`, `assertEqual`, etc. with checks on a spy or call. They perform the necessary checks and then provide detailed information if the assertion goes wrong. The following assertion methods are implemented: * `assertHasSpy` * `assertSpyCalled` * `assertSpyNotCalled` * `assertSpyCallCount` * `assertSpyCalledWith` * `assertSpyLastCalledWith` * `assertSpyReturned` * `assertSpyLastReturned` * `assertSpyRaised` * `assertSpyLastRaised` * `assertSpyRaisedMessage` * `assertSpyLastRaisedMessage` New code should use these assertion methods for best results. The README has been updated to show both the new-style and old-style assertions.
8ed670568b3f0a6317636dbad24a0e6b10a69af9
Description From Last Updated

E303 too many blank lines (2)

reviewbotreviewbot
chipx86
Review request changed

Change Summary:

Added assertSpyNotCalled

Description:

   

KGB is hitting 5.0, and for the first time, it's getting its own

    assertion methods.

   
   

These are designed to replace the usage of assertTrue, assertEqual,

    etc. with checks on a spy or call. They perform the necessary checks and
    then provide detailed information if the assertion goes wrong.

   
   

The following assertion methods are implemented:

   
   
  • assertHasSpy
   
  • assertSpyCalled
~  
  • assertSpyCallCount
~  
  • assertSpyCalledWith
~  
  • assertSpyLastCalledWith
~  
  • assertSpyReturned
~  
  • assertSpyLastReturned
~  
  • assertSpyRaised
~  
  • assertSpyLastRaised
~  
  • assertSpyRaisedMessage
~  
  • assertSpyLastRaisedMessage
  ~
  • assertSpyNotCalled
  ~
  • assertSpyCallCount
  ~
  • assertSpyCalledWith
  ~
  • assertSpyLastCalledWith
  ~
  • assertSpyReturned
  ~
  • assertSpyLastReturned
  ~
  • assertSpyRaised
  ~
  • assertSpyLastRaised
  ~
  • assertSpyRaisedMessage
  +
  • assertSpyLastRaisedMessage
   
   

New code should use these assertion methods for best results.

   
   

The README has been updated to show both the new-style and old-style

    assertions.

Commits:

Summary ID
Add new assertion methods for checking spies.
KGB is hitting 5.0, and for the first time, it's getting its own assertion methods. These are designed to replace the usage of `assertTrue`, `assertEqual`, etc. with checks on a spy or call. They perform the necessary checks and then provide detailed information if the assertion goes wrong. The following assertion methods are implemented: * `assertHasSpy` * `assertSpyCalled` * `assertSpyCallCount` * `assertSpyCalledWith` * `assertSpyLastCalledWith` * `assertSpyReturned` * `assertSpyLastReturned` * `assertSpyRaised` * `assertSpyLastRaised` * `assertSpyRaisedMessage` * `assertSpyLastRaisedMessage` New code should use these assertion methods for best results. The README has been updated to show both the new-style and old-style assertions.
22c3ae82fde88d6be75e97033bbe9e899df106da
Add new assertion methods for checking spies.
KGB is hitting 5.0, and for the first time, it's getting its own assertion methods. These are designed to replace the usage of `assertTrue`, `assertEqual`, etc. with checks on a spy or call. They perform the necessary checks and then provide detailed information if the assertion goes wrong. The following assertion methods are implemented: * `assertHasSpy` * `assertSpyCalled` * `assertSpyNotCalled` * `assertSpyCallCount` * `assertSpyCalledWith` * `assertSpyLastCalledWith` * `assertSpyReturned` * `assertSpyLastReturned` * `assertSpyRaised` * `assertSpyLastRaised` * `assertSpyRaisedMessage` * `assertSpyLastRaisedMessage` New code should use these assertion methods for best results. The README has been updated to show both the new-style and old-style assertions.
8ed670568b3f0a6317636dbad24a0e6b10a69af9

Diff:

Revision 2 (+2802 -22)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (aca2360)
Loading...