예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #5
0
파일: spy.py 프로젝트: Avvir/pyne
 def get_spy(object):
     if isinstance(object, Spy):
         return object
     return AttachedSpy.get_spy(object)