Example #1
0
    def test_new_allowances_can_be_set(self):
        (allow(doubles.testing).top_level_function.with_args(
            'Bob Barker').and_return('Drew Carey'))

        clear(doubles.testing)
        allow(doubles.testing).top_level_function.and_return('Bob Barker')

        assert doubles.testing.top_level_function('bar') == 'Bob Barker'
Example #2
0
    def test_new_allowances_can_be_set(self):
        (allow(doubles.testing).
            top_level_function.
            with_args('Bob Barker').
            and_return('Drew Carey'))

        clear(doubles.testing)
        allow(doubles.testing).top_level_function.and_return('Bob Barker')

        assert doubles.testing.top_level_function('bar') == 'Bob Barker'
Example #3
0
    def test_clearing_an_instance(self):
        user = doubles.testing.User('Bob Barker', 25)
        (allow(user).method_with_positional_arguments.with_args(25).and_return(
            'The price is right'))

        clear(user)
        allow(user).method_with_positional_arguments.and_return(
            'The price is wrong')

        assert user.method_with_positional_arguments(
            10) == 'The price is wrong'
Example #4
0
    def test_clearing_an_instance(self):
        user = doubles.testing.User('Bob Barker', 25)
        (allow(user).
            method_with_positional_arguments.
            with_args(25).
            and_return('The price is right'))

        clear(user)
        allow(user).method_with_positional_arguments.and_return('The price is wrong')

        assert user.method_with_positional_arguments(10) == 'The price is wrong'
Example #5
0
    def test_calling_on_an_undoubled_object(self):
        clear(doubles.testing)

        result = doubles.testing.top_level_function('bob')
        assert result == 'bob -- default'
Example #6
0
 def test_calling_twice(self):
     expect(doubles.testing).top_level_function
     clear(doubles.testing)
     clear(doubles.testing)
Example #7
0
 def test_does_not_raise_expectation_errors(self):
     expect(doubles.testing).top_level_function
     clear(doubles.testing)
Example #8
0
    def test_calling_on_an_undoubled_object(self):
        clear(doubles.testing)

        result = doubles.testing.top_level_function('bob')
        assert result == 'bob -- default'
Example #9
0
 def test_calling_twice(self):
     expect(doubles.testing).top_level_function
     clear(doubles.testing)
     clear(doubles.testing)
Example #10
0
 def test_does_not_raise_expectation_errors(self):
     expect(doubles.testing).top_level_function
     clear(doubles.testing)