cython

Форк
0
/
bound_builtin_methods_T589.pyx 
118 строк · 1.9 Кб
1
# ticket: t589
2

3
cimport cython
4

5
_set = set # CPython may not define it (in Py2.3), but Cython does :)
6

7

8
def test_set_clear_bound():
9
    """
10
    >>> type(test_set_clear_bound()) is _set
11
    True
12
    >>> list(test_set_clear_bound())
13
    []
14
    """
15
    cdef set s1 = set([1])
16
    clear = s1.clear
17
    clear()
18
    return s1
19

20
text = u'ab jd  sdflk as sa  sadas asdas fsdf '
21
pipe_sep = u'|'
22

23

24
@cython.test_assert_path_exists(
25
    "//PythonCapiCallNode",
26
)
27
def test_unicode_join_bound(unicode sep, l):
28
    """
29
    >>> l = text.split()
30
    >>> len(l)
31
    8
32
    >>> print( pipe_sep.join(l) )
33
    ab|jd|sdflk|as|sa|sadas|asdas|fsdf
34
    >>> print( test_unicode_join_bound(pipe_sep, l) )
35
    ab|jd|sdflk|as|sa|sadas|asdas|fsdf
36
    """
37
    join = sep.join
38
    return join(l)
39

40

41
def test_unicode_join_bound_no_assignment(unicode sep):
42
    """
43
    >>> test_unicode_join_bound_no_assignment(text)
44
    """
45
    sep.join
46

47

48
def test_dict_items_bound_no_assignment(dict d):
49
    """
50
    >>> test_dict_items_bound_no_assignment({1:2})
51
    """
52
    d.items
53

54

55
def list_pop(list l):
56
    """
57
    >>> list_pop([1,2,3])
58
    (2, [1, 3])
59
    """
60
    pop = l.pop
61
    r = pop(1)
62
    return r, l
63

64

65
def list_pop_literal():
66
    """
67
    >>> list_pop_literal()
68
    (2, [1, 3])
69
    """
70
    l = [1,2,3]
71
    pop = l.pop
72
    r = pop(1)
73
    return r, l
74

75

76
def list_pop_reassign():
77
    """
78
    >>> list_pop_reassign()
79
    2
80
    """
81
    l = [1,2,3]
82
    pop = l.pop
83
    l = None
84
    r = pop(1)
85
    return r
86

87

88
def list_insert(list l):
89
    """
90
    >>> list_insert([1,2,3])
91
    (None, [1, 4, 2, 3])
92
    """
93
    insert = l.insert
94
    r = insert(1, 4)
95
    return r, l
96

97

98
def list_insert_literal():
99
    """
100
    >>> list_insert_literal()
101
    (None, [1, 4, 2, 3])
102
    """
103
    l = [1,2,3]
104
    insert = l.insert
105
    r = insert(1, 4)
106
    return r, l
107

108

109
def list_insert_reassign():
110
    """
111
    >>> list_insert_reassign()
112
    (None, [1, 4, 2, 3])
113
    """
114
    l = [1,2,3]
115
    insert = l.insert
116
    m, l = l, None
117
    r = insert(1, 4)
118
    return r, m
119

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.