本文整理汇总了Python中cffi.verifier.Verifier.write_source方法的典型用法代码示例。如果您正苦于以下问题:Python Verifier.write_source方法的具体用法?Python Verifier.write_source怎么用?Python Verifier.write_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cffi.verifier.Verifier
的用法示例。
在下文中一共展示了Verifier.write_source方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_source
# 需要导入模块: from cffi.verifier import Verifier [as 别名]
# 或者: from cffi.verifier.Verifier import write_source [as 别名]
def test_write_source(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
v.write_source()
with open(v.sourcefilename, 'r') as f:
data = f.read()
assert csrc in data
示例2: test_write_source_explicit_filename
# 需要导入模块: from cffi.verifier import Verifier [as 别名]
# 或者: from cffi.verifier.Verifier import write_source [as 别名]
def test_write_source_explicit_filename(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic,
libraries=[self.lib_m])
v.sourcefilename = filename = str(udir.join('write_source.c'))
v.write_source()
assert filename == v.sourcefilename
with open(filename, 'r') as f:
data = f.read()
assert csrc in data
示例3: test_write_source_to_file_obj
# 需要导入模块: from cffi.verifier import Verifier [as 别名]
# 或者: from cffi.verifier.Verifier import write_source [as 别名]
def test_write_source_to_file_obj(self):
ffi = FFI()
ffi.cdef("double sin(double x);")
csrc = '/*hi there %s!*/\n#include <math.h>\n' % self
v = Verifier(ffi, csrc, force_generic_engine=self.generic)
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
f = StringIO()
v.write_source(file=f)
assert csrc in f.getvalue()