Fix spying on functions belonging to falsy objects.

Review Request #7778 — Created Nov. 23, 2015 and submitted

Information

kgb
master

Reviewers

kgb
When spying on a function that belonged to an object that evaluated the
false, the spy would be created on the class and not the instance. This
would end up polluting any future spies, as the spy would stick around
on the class long-term but be bound to the state of the original
instance.

This happened because we checked if a value was truthy/falsy, when what
we wanted was to check whether it was None. The check is now more
specific, fixing this case.

Unit tests pass.

My original case where I hit this now succeeds.

reviewbot
  1. Tool: Pyflakes
    Processed Files:
        kgb/tests.py
        kgb/spies.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        kgb/tests.py
        kgb/spies.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (4a0243a)