How to use boost method in hypothesis

Best Python code snippet using hypothesis

boost.py

Source:boost.py Github

copy

Full Screen

...20 opt.load('compiler_cxx boost')2122def configure(conf):23 conf.load('compiler_cxx boost')24 conf.check_boost(lib='system filesystem', mt=True, static=True)2526def build(bld):27 bld(source='main.cpp', target='app', use='BOOST')28'''2930import sys31import re32from waflib import Utils, Logs33from waflib.Configure import conf34from waflib.Errors import WafError3536BOOST_LIBS = ('/usr/lib', '/usr/local/lib',37 '/opt/local/lib', '/sw/lib', '/lib')38BOOST_INCLUDES = ('/usr/include', '/usr/local/include',39 '/opt/local/include', '/sw/include')40BOOST_VERSION_FILE = 'boost/version.hpp'41BOOST_VERSION_CODE = '''42#include <iostream>43#include <boost/version.hpp>44int main() { std::cout << BOOST_LIB_VERSION << std::endl; }45'''4647# toolsets from {boost_dir}/tools/build/v2/tools/common.jam48PLATFORM = Utils.unversioned_sys_platform()49detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'50detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'51detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'52BOOST_TOOLSETS = {53 'borland': 'bcb',54 'clang': detect_clang,55 'como': 'como',56 'cw': 'cw',57 'darwin': 'xgcc',58 'edg': 'edg',59 'g++': detect_mingw,60 'gcc': detect_mingw,61 'icpc': detect_intel,62 'intel': detect_intel,63 'kcc': 'kcc',64 'kylix': 'bck',65 'mipspro': 'mp',66 'mingw': 'mgw',67 'msvc': 'vc',68 'qcc': 'qcc',69 'sun': 'sw',70 'sunc++': 'sw',71 'tru64cxx': 'tru',72 'vacpp': 'xlc'73}747576def options(opt):77 opt.add_option('--boost-includes', type='string',78 default='', dest='boost_includes',79 help='''path to the boost directory where the includes are80 e.g. /boost_1_45_0/include''')81 opt.add_option('--boost-libs', type='string',82 default='', dest='boost_libs',83 help='''path to the directory where the boost libs are84 e.g. /boost_1_45_0/stage/lib''')85 opt.add_option('--boost-static', action='store_true',86 default=False, dest='boost_static',87 help='link static libraries')88 opt.add_option('--boost-mt', action='store_true',89 default=False, dest='boost_mt',90 help='select multi-threaded libraries')91 opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',92 help='''select libraries with tags (dgsyp, d for debug),93 see doc Boost, Getting Started, chapter 6.1''')94 opt.add_option('--boost-toolset', type='string',95 default='', dest='boost_toolset',96 help='force a toolset e.g. msvc, vc90, \97 gcc, mingw, mgw45 (default: auto)')98 py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])99 opt.add_option('--boost-python', type='string',100 default=py_version, dest='boost_python',101 help='select the lib python with this version \102 (default: %s)' % py_version)103104105@conf106def __boost_get_version_file(self, dir):107 try:108 return self.root.find_dir(dir).find_node(BOOST_VERSION_FILE)109 except:110 return None111112113@conf114def boost_get_version(self, dir):115 """silently retrieve the boost version number"""116 re_but = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"$', re.M)117 try:118 val = re_but.search(self.__boost_get_version_file(dir).read()).group(1)119 except:120 val = self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[dir],121 execute=True, define_ret=True)122 return val123124125@conf126def boost_get_includes(self, *k, **kw):127 includes = k and k[0] or kw.get('includes', None)128 if includes and self.__boost_get_version_file(includes):129 return includes130 for dir in BOOST_INCLUDES:131 if self.__boost_get_version_file(dir):132 return dir133 if includes:134 self.fatal('headers not found in %s' % includes)135 else:136 self.fatal('headers not found, use --boost-includes=/path/to/boost')137138139@conf140def boost_get_toolset(self, cc):141 toolset = cc142 if not cc:143 build_platform = Utils.unversioned_sys_platform()144 if build_platform in BOOST_TOOLSETS:145 cc = build_platform146 else:147 cc = self.env.CXX_NAME148 if cc in BOOST_TOOLSETS:149 toolset = BOOST_TOOLSETS[cc]150 return isinstance(toolset, str) and toolset or toolset(self.env)151152153@conf154def __boost_get_libs_path(self, *k, **kw):155 ''' return the lib path and all the files in it '''156 if 'files' in kw:157 return self.root.find_dir('.'), Utils.to_list(kw['files'])158 libs = k and k[0] or kw.get('libs', None)159 if libs:160 path = self.root.find_dir(libs)161 files = path.ant_glob('*boost_*')162 if not libs or not files:163 for dir in BOOST_LIBS:164 try:165 path = self.root.find_dir(dir)166 files = path.ant_glob('*boost_*')167 if files:168 break169 path = self.root.find_dir(dir + '64')170 files = path.ant_glob('*boost_*')171 if files:172 break173 except:174 path = None175 if not path:176 if libs:177 self.fatal('libs not found in %s' % libs)178 else:179 self.fatal('libs not found, \180 use --boost-includes=/path/to/boost/lib')181 return path, files182183184@conf185def boost_get_libs(self, *k, **kw):186 '''187 return the lib path and the required libs188 according to the parameters189 '''190 path, files = self.__boost_get_libs_path(**kw)191 t = []192 if kw.get('mt', False):193 t.append('mt')194 if kw.get('abi', None):195 t.append(kw['abi'])196 tags = t and '(-%s)+' % '-'.join(t) or ''197 toolset = '(-%s[0-9]{0,3})+' % self.boost_get_toolset(kw.get('toolset', ''))198 version = '(-%s)+' % self.env.BOOST_VERSION199200 def find_lib(re_lib, files):201 for file in files:202 if re_lib.search(file.name):203 return file204 return None205206 def format_lib_name(name):207 if name.startswith('lib'):208 name = name[3:]209 return name.split('.')[0]210211 libs = []212 for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):213 py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''214 # Trying libraries, from most strict match to least one215 for pattern in ['boost_%s%s%s%s%s' % (lib, toolset, tags, py, version),216 'boost_%s%s%s%s' % (lib, tags, py, version),217 'boost_%s%s%s' % (lib, tags, version),218 # Give up trying to find the right version219 'boost_%s%s%s%s' % (lib, toolset, tags, py),220 'boost_%s%s%s' % (lib, tags, py),221 'boost_%s%s' % (lib, tags)]:222 file = find_lib(re.compile(pattern), files)223 if file:224 libs.append(format_lib_name(file.name))225 break226 else:227 self.fatal('lib %s not found in %s' % (lib, path))228229 return path.abspath(), libs230231232@conf233def check_boost(self, *k, **kw):234 """235 initialize boost236237 You can pass the same parameters as the command line (without "--boost-"),238 but the command line has the priority.239 """240 if not self.env['CXX']:241 self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')242243 params = {'lib': k and k[0] or kw.get('lib', None)}244 for key, value in self.options.__dict__.items():245 if not key.startswith('boost_'):246 continue247 key = key[len('boost_'):] ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful