예제 #1
0
    def test_mix_any_matcher_with_exact_value_fails_on_different_value(self):
        '''
        Mixed any matcher and exact value parameter expectation must fail
        if exact value is different
        '''
        mock = mockaccino.create_mock(self.MockedClass)

        mock.method_with_two_parameters(1, any(basestring)).always()

        mockaccino.replay(mock)

        mock.method_with_two_parameters(2, "a")
예제 #2
0
    def test_matcher_any_int(self):
        '''
        The "any" type matcher should also work for primitive types
        '''
        mock = mockaccino.create_mock(self.MockedClass)

        mock.method_with_parameter(any(int)).always()

        mockaccino.replay(mock)

        mock.method_with_parameter(0)
        mock.method_with_parameter(1)
예제 #3
0
    def test_mix_any_matcher_with_exact_value(self):
        '''
        Any matcher and exact value parameter expectations can be mixed
        '''
        mock = mockaccino.create_mock(self.MockedClass)

        mock.method_with_two_parameters(1, any(basestring)).always()

        mockaccino.replay(mock)

        mock.method_with_two_parameters(1, "a")
        mock.method_with_two_parameters(1, "cat")
        mock.method_with_two_parameters(1, "dog")
예제 #4
0
    def test_matcher_any_fails_on_different_class(self):
        '''
        The "any" type matcher should not match values with different classes
        '''
        def function_to_mock(self, cls):
            pass

        mock = mockaccino.create_mock(function_to_mock)
        mock(any(self.MockedClass))

        mockaccino.replay(mock)

        mock("not a mocked class!")
예제 #5
0
    def test_matcher_any_class(self):
        '''
        Tests "any" type matcher for classes
        '''
        def function_to_mock(self, cls):
            pass

        mock = mockaccino.create_mock(function_to_mock)
        mock(any(self.MockedClass)).times(2)

        mockaccino.replay(mock)

        mock(self.MockedClass())
        mock(self.MockedClass())