summaryrefslogtreecommitdiff
path: root/mock/tests/testhelpers_py3.py
blob: 2af91b50444c0a5d0467aa0f86f90de2c255eb87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import inspect
import unittest

from mock import call, create_autospec


class CallTest(unittest.TestCase):


    def test_spec_inspect_signature_annotations(self):

        def foo(a: int, b: int=10, *, c:int) -> int:
            return a + b + c

        mock = create_autospec(foo)
        mock(1, 2, c=3)
        mock(1, c=3)

        self.assertEqual(inspect.getfullargspec(mock), inspect.getfullargspec(foo))
        self.assertEqual(mock.mock_calls, [call(1, 2, c=3), call(1, c=3)])
        self.assertRaises(TypeError, mock, 1)
        self.assertRaises(TypeError, mock, 1, 2, 3, c=4)