summaryrefslogtreecommitdiff
path: root/tests/run/cdef_classmethod.pyx
blob: 86891e4dfec2034eb9aad163c889b3c2caa412e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

cimport cython

cdef class cclass:

    @classmethod
    def test0(cls):
        """
        >>> cclass.test0()
        'type object'
        """
        return cython.typeof(cls)

    @classmethod
    def test0_args(*args):
        """
        >>> cclass.test0_args(1,2,3)
        ('Python object', (1, 2, 3))
        """
        return cython.typeof(args[0]), args[1:]

    @classmethod
    def test1(cls, arg):
        """
        >>> cclass.test1(1)
        ('type object', 1)
        """
        return cython.typeof(cls), arg

    @classmethod
    def test2(cls, arg1, arg2):
        """
        >>> cclass.test2(1,2)
        ('type object', 1, 2)
        """
        return cython.typeof(cls), arg1, arg2

    @classmethod
    def test1_args(cls, *args):
        """
        >>> cclass.test1_args(1,2,3)
        ('type object', (1, 2, 3))
        """
        return cython.typeof(cls), args

    @classmethod
    def test2_args(cls, arg, *args):
        """
        >>> cclass.test2_args(1,2,3)
        ('type object', 1, (2, 3))
        """
        return cython.typeof(cls), arg, args

    @classmethod
    def test0_args_kwargs(*args, **kwargs):
        """
        >>> cclass.test0_args_kwargs(1,2,3)
        ('Python object', (1, 2, 3), {})
        """
        return cython.typeof(args[0]), args[1:], kwargs

    @classmethod
    def test1_args_kwargs(cls, *args, **kwargs):
        """
        >>> cclass.test1_args_kwargs(1,2,3)
        ('type object', (1, 2, 3), {})
        """
        return cython.typeof(cls), args, kwargs

    @classmethod
    def test2_args_kwargs(cls, arg, *args, **kwargs):
        """
        >>> cclass.test2_args_kwargs(1,2,3)
        ('type object', 1, (2, 3), {})
        """
        return cython.typeof(cls), arg, args, kwargs