from python_ref cimport PyObject
__test__ = {}
-setup_string = u"""
- >>> A = IntMockBuffer("A", range(6))
- >>> B = IntMockBuffer("B", range(6))
- >>> C = IntMockBuffer("C", range(6), (2,3))
- >>> E = ErrorBuffer("E")
-
-"""
import re
exclude = []#re.compile('object').search]
for e in exclude:
if e(func.__name__):
return func
- __test__[func.__name__] = setup_string + func.__doc__
+ __test__[func.__name__] = func.__doc__
return func
def testcas(a):
@testcase
def acquire_release(o1, o2):
"""
+ >>> A = IntMockBuffer("A", range(6))
+ >>> B = IntMockBuffer("B", range(6))
>>> acquire_release(A, B)
acquired A
released A
Apparently, doctest won't handle mixed exceptions and print
stats, so need to circumvent this.
+ >>> A = IntMockBuffer("A", range(6))
>>> A.resetlog()
>>> acquire_raise(A)
Traceback (most recent call last):
@testcase
def as_argument(object[int] bufarg, int n):
"""
+ >>> A = IntMockBuffer("A", range(6))
>>> as_argument(A, 6)
acquired A
0 1 2 3 4 5 END
acquired default
0 1 2 3 4 5 END
released default
+ >>> A = IntMockBuffer("A", range(6))
>>> as_argument_defval(A, 6)
acquired A
0 1 2 3 4 5 END
@testcase
def cdef_assignment(obj, n):
"""
+ >>> A = IntMockBuffer("A", range(6))
>>> cdef_assignment(A, 6)
acquired A
0 1 2 3 4 5 END
@testcase
def forin_assignment(objs, int pick):
"""
+ >>> A = IntMockBuffer("A", range(6))
+ >>> B = IntMockBuffer("B", range(6))
>>> forin_assignment([A, B, A, A], 2)
acquired A
2
@testcase
def cascaded_buffer_assignment(obj):
"""
+ >>> A = IntMockBuffer("A", range(6))
>>> cascaded_buffer_assignment(A)
acquired A
acquired A
@testcase
def tuple_buffer_assignment1(a, b):
"""
+ >>> A = IntMockBuffer("A", range(6))
+ >>> B = IntMockBuffer("B", range(6))
>>> tuple_buffer_assignment1(A, B)
acquired A
acquired B
@testcase
def tuple_buffer_assignment2(tup):
"""
+ >>> A = IntMockBuffer("A", range(6))
+ >>> B = IntMockBuffer("B", range(6))
>>> tuple_buffer_assignment2((A, B))
acquired A
acquired B
@testcase
def get_int_2d(object[int, ndim=2] buf, int i, int j):
"""
+ >>> C = IntMockBuffer("C", range(6), (2,3))
>>> get_int_2d(C, 1, 1)
acquired C
released C
def get_int_2d_uintindex(object[int, ndim=2] buf, unsigned int i, unsigned int j):
"""
Unsigned indexing:
+ >>> C = IntMockBuffer("C", range(6), (2,3))
>>> get_int_2d_uintindex(C, 0, 0)
acquired C
released C
Uses get_int_2d to read back the value afterwards. For pure
unit test, one should support reading in MockBuffer instead.
+ >>> C = IntMockBuffer("C", range(6), (2,3))
>>> set_int_2d(C, 1, 1, 10)
acquired C
released C