Example #1
0
    def __rshift__(self, value, act=False):
        """syntax sugar for more concise expect/result expression syntax

        old:  expect(mock.func(arg)).result(value)
        new: mock.func(arg) >> value

        This variation has a subtle difference from the 'sour' code above as
        well as the << operator. It returns 'value' rather than the expect
        object, which allows us to construct expressions while "injecing"
        return values into sub-expressions. For example:

            (mock.func(arg) >> value).value_func()

            Equivalent to:

            expect(mock.func(arg)).result(value)
            value.value_func()

        Note: to mock a real right-shift operation use the following code in
        your test case:

            mock.func(arg).__rshift__(value, act=True)
        """
        if self.__mocker__.is_recording() and not act:
            mocker.expect(self).result(value)
            return value
        return self.__mocker_act__("__rshift__", (value,))
Example #2
0
    def __rshift__(self, value, act=False):
        """syntax sugar for more concise expect/result expression syntax

        old:  expect(mock.func(arg)).result(value)
        new: mock.func(arg) >> value

        This variation has a subtle difference from the 'sour' code above as
        well as the << operator. It returns 'value' rather than the expect
        object, which allows us to construct expressions while "injecing"
        return values into sub-expressions. For example:

            (mock.func(arg) >> value).value_func()

            Equivalent to:

            expect(mock.func(arg)).result(value)
            value.value_func()

        Note: to mock a real right-shift operation use the following code in
        your test case:

            mock.func(arg).__rshift__(value, act=True)
        """
        if self.__mocker__.is_recording() and not act:
            mocker.expect(self).result(value)
            return value
        return self.__mocker_act__("__rshift__", (value, ))
Example #3
0
    def __lshift__(self, value, act=False):
        """syntax sugar for more concise expect/result expression syntax

        old:  expect(mock.func(arg)).result(value)
        new: mock.func(arg) << value

        Note: to mock a real left-shift operation use the following code in
        your test case:

            mock.func(arg).__lshift__(value, act=True)
        """
        if self.__mocker__.is_recording() and not act:
            return mocker.expect(self).result(value)
        return self.__mocker_act__("__lshift__", (value,))
Example #4
0
    def __lshift__(self, value, act=False):
        """syntax sugar for more concise expect/result expression syntax

        old:  expect(mock.func(arg)).result(value)
        new: mock.func(arg) << value

        Note: to mock a real left-shift operation use the following code in
        your test case:

            mock.func(arg).__lshift__(value, act=True)
        """
        if self.__mocker__.is_recording() and not act:
            return mocker.expect(self).result(value)
        return self.__mocker_act__("__lshift__", (value, ))