Exemple #1
0
 def _(self):
     some_instance = SomeClass()
     with stub(some_instance.some_method).then_return(
             "some_value") as spy:
         result = some_instance.some_method("anything", ["can"],
                                            go="here")
         expect(result).to_be("some_value")
Exemple #2
0
 def _(self):
     some_instance = SomeClass()
     with stub(some_instance.some_method) as spy:
         some_instance.some_method("anything", ["can"], go="here")
         expect(spy.last_call).to_be((("anything", ["can"]), {
             "go": "here"
         }))
Exemple #3
0
 def _(self):
     with stub(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(Spy.get_spy(SomeClass.some_class_method)).to_be(spy)
Exemple #4
0
 def _(self):
     some_instance = SomeClass()
     with stub('some_method', on=some_instance) as spy:
         some_instance.some_method("some_arg 123")
         expect(spy.last_call).to_be((("some_arg 123", ), {}))
         expect(Spy.get_spy(
             some_instance.some_method)).to_be(spy)
Exemple #5
0
        def _(self):
            some_instance = SomeOtherClass()

            with stub(some_instance.some_function).call_real():
                result = some_instance.some_function("anything", ["can"],
                                                     go="here")
                expect(result).to_be("some_value")
Exemple #6
0
        def _(self):
            some_instance = SomeClass()

            def some_function(*args, **kwargs):
                return "some_value"

            some_instance.some_function = some_function
            expect(lambda: stub(some_instance.some_function)
                   ).to_raise_error_of_type(ValueError)
Exemple #7
0
 def _(self):
     with stub(some_class.some_module_method, on=some_class) as spy:
         some_class.some_module_method("anything", ["can"],
                                       go="here")
         expect(spy.last_call).to_be((("anything", ["can"]), {
             "go": "here"
         }))
         expect(Spy.get_spy(
             some_class.some_module_method)).to_be(spy)
Exemple #8
0
 def _(self):
     some_instance = SomeOtherClass()
     original_function = some_instance.some_function
     with stub(some_instance.some_function) as spy:
         some_instance.some_function("anything", ["can"], go="here")
         expect(spy.last_call).to_be((("anything", ["can"]), {
             "go": "here"
         }))
     expect(spy.last_call).to_be_none()
     expect(some_instance.some_function).to_be(original_function)
Exemple #9
0
 def spy(self, object_to_stub=None, method=None):
     new_spy = stub(object_to_stub, method)
     self._spies.append(new_spy)
     return new_spy
Exemple #10
0
 def _(self):
     expect(lambda: stub(SomeClass.some_method)
            ).to_raise_error_of_type(ValueError)
Exemple #11
0
 def _(self):
     some_instance = SomeClass()
     expect(lambda: stub(some_instance.some_decorated_method)
            ).to_raise_error_of_type(ValueError)