Example #1
0
 def _(self):
     some_instance = SomeClass()
     with AttachedSpy(some_instance, "some_method") as spy:
         some_instance.some_method("some_arg")
         expect(spy.last_call).to_be((("some_arg", ), {}))
         expect(AttachedSpy.get_spy(
             some_instance.some_method)).to_be(spy)
Example #2
0
 def _(self):
     with AttachedSpy(SomeClass, "some_class_method") as spy:
         SomeClass.some_class_method("anything", ["can"], go="here")
         expect(spy.last_call).to_be((("anything", ["can"]), {
             "go": "here"
         }))
         expect(AttachedSpy.get_spy(
             SomeClass.some_class_method)).to_be(spy)
Example #3
0
 def _(self):
     with AttachedSpy(SomeClass, "some_method",
                      needs_binding=True) as spy:
         some_instance = SomeClass()
         some_instance.some_method("some_arg")
         expect(spy.last_call).to_be((("some_arg", ), {}))
         expect(AttachedSpy.get_spy(
             some_instance.some_method)).to_be(spy)
Example #4
0
 def _(self):
     some_instance = SomeClass()
     with AttachedSpy(some_instance,
                      "some_decorated_method") as spy:
         some_instance.some_decorated_method("anything", ["can"],
                                             go="here")
         expect(spy.last_call).to_be((("anything", ["can"]), {
             "go": "here"
         }))
         expect(
             AttachedSpy.get_spy(
                 some_instance.some_decorated_method)).to_be(spy)
Example #5
0
File: spy.py Project: Avvir/pyne
 def get_spy(object):
     if isinstance(object, Spy):
         return object
     return AttachedSpy.get_spy(object)