def test_FILE_only_for_FILE_arg():
if sys.platform == "win32":
py.test.skip("testing FILE not implemented")
#
B_NOT_FILE = new_struct_type("struct NOT_FILE")
B_NOT_FILEP = new_pointer_type(B_NOT_FILE)
BChar = new_primitive_type("char")
BCharP = new_pointer_type(BChar)
BInt = new_primitive_type("int")
BFunc = new_function_type((BCharP, B_NOT_FILEP), BInt, False)
ll = find_and_load_library('c')
fputs = ll.load_function(BFunc, "fputs")
#
import posix
fdr, fdw = posix.pipe()
fr1 = posix.fdopen(fdr, 'r')
fw1 = posix.fdopen(fdw, 'w')
#
e = py.test.raises(TypeError, fputs, b"hello world\n", fw1)
assert str(e.value).startswith(
"initializer for ctype 'struct NOT_FILE *' must "
"be a cdata pointer, not ")
评论列表
文章目录