コード例 #1
0
ファイル: attached_spy_test.py プロジェクト: Avvir/pyne
 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
ファイル: attached_spy_test.py プロジェクト: Avvir/pyne
 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
ファイル: attached_spy_test.py プロジェクト: Avvir/pyne
 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
ファイル: attached_spy_test.py プロジェクト: Avvir/pyne
 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)