Best Python code snippet using hypothesis
primitive.py
Source:primitive.py  
...48    def has_tags(self):49        self.components50        return self.__dict__['has_tags']51    @cached_property52    def has_strings(self):53        self.components54        return self.__dict__['has_strings']55    @cached_property56    def components(self):57        self.__dict__.update({key: False for key in ('has_primitives', 'has_terms', 'has_tags', 'has_strings')})58        components = []59        for primitive, term, tag, string in regex_optionalvalue_components.findall(self.definition):60            if primitive:61                components.append(PrimitiveComponent(primitive))62                self.__dict__['has_primitives'] = True63            elif term:64                components.append(TermComponent(term))65                self.__dict__['has_terms'] = True66            elif tag:67                components.append(TagComponent(tag))68                self.__dict__['has_tags'] = True69            elif string:70                components.append(StringComponent(string))71                self.__dict__['has_strings'] = True72            else:73                # Should not have made it to this point.74                raise ValueError("The definition string for the option was malformed.")75        return components76DEFAULT_OPTIONS_DEFINITION = "<TEXT>"77class OptionalValues(list):78    79    @cached_property80    def has_primitives(self):81        return any(ov.has_primitives for ov in self)82    @cached_property83    def has_terms(self):84        return any(ov.has_terms for ov in self)85    @cached_property86    def has_tags(self):87        return any(ov.has_tags for ov in self)88    @cached_property89    def has_strings(self):90        return any(ov.has_strings for ov in self)91class Primitive(SchemaElement):92    def __init__(self, *, label:str, size_min:str, size_max:str=None, **kwargs):93        super().__init__(**kwargs)94        self.label = label95        self.size_min = int(size_min)96        self.size_max = int(size_max) if size_max else self.size_min97        self.description = ""98        self.terms = None99        # Create the default optional values definition, which may be overriden later.100        self.optional_values = OptionalValues()101        self.optional_values.append(OptionalValue(DEFAULT_OPTIONS_DEFINITION, self))102    103    @property...radare2.py
Source:radare2.py  
1import shutil2import subprocess3import json4import r2pipe5FIELD_MAPPING = {6    # json7    'classes': 'icj',8    'libraries': 'ilj',9    'meta': 'iIj',10    'imports': 'iij',11    'exports': 'iEj',12    'segments': 'iSj',13    'entries': 'ieej'14}15HAS_STRINGS = bool(shutil.which('strings'))16HAS_CLASS_DUMP = bool(shutil.which('class-dump'))17def parse(path, entity):18    r2 = r2pipe.open(path, ['-2'])19    strings_failed = False20    if HAS_STRINGS:21        try:22            entity.strings = subprocess.check_output(23                ['strings', path]).decode('utf8')24        except:25            strings_failed = True26    if strings_failed or not HAS_STRINGS:  # fallback to r2 (much slower)27        entity.strings = '\n'.join([28            s.get('string')29            for s in json.loads(r2.cmd('izzj')).get('strings')])30    class_dump_failed = False31    if HAS_CLASS_DUMP:32        try:33            entity.classdump = subprocess.check_output(34                ['class-dump', path], stderr=subprocess.DEVNULL).decode('utf8')35        except:36            class_dump_failed = True37    if class_dump_failed or not HAS_CLASS_DUMP:38        entity.classdump = r2.cmd('icc')39    for key, cmd in FIELD_MAPPING.items():40        val = r2.cmd(cmd)41        if not val:42            continue43        obj = json.loads(val)...oop1inheritence.py
Source:oop1inheritence.py  
1class Instrument(object):2	def __init__(self, name):3		self.name = name4	def has_strings(self):5		return True6class StringInstrument(Instrument):7	def __init__(self, name, count):8		# super(StringInstrument,self).__init__(name)9		Instrument.__init__(self, name)10		self.count = count11class Guitar(StringInstrument):12	def __init__(self):13		# super(Guitar, self).__init__('guitar', 6)14		StringInstrument.__init__(self, 'guitar', 6)15# class PercussionInstrument(Instrument):16# 	def has_strings(self):17# 		return False18# guitar = Instrument('guitar')19# drums = PercussionInstrument('drums')20guitar = Guitar()21# print 'Guitar has strings: {0}'.format(guitar.has_strings())22print 'Guitar name: {0}'.format(guitar.name)23# print 'Drums have strings: {0}'.format(drums.has_strings())24# print 'Drums name: {0}'.format(drums.name)...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
