How to use is_list_or_tuple method in localstack

Best Python code snippet using localstack_python

unit_test.py

Source:unit_test.py Github

copy

Full Screen

...131 if len(test) == len(solution):132 return all([self.validate(tt, ss, type(ss)) for (tt,ss) in zip(test, solution)])133 else:134 return False135 def is_list_or_tuple(self, test):136 return isinstance(test, list) or isinstance(test, tuple)137 #Should check length of results/solutions/dtypes 138 def validate_all(self, results, solutions, dtypes):139 if not isinstance(results, list):140 results = [results]141 if not isinstance(solutions, list):142 solutions = [solutions]143 if not isinstance(dtypes, list):144 dtypes = [dtypes]145 146 147 validation = []148 for (result, solution, dtype) in zip(results, solutions, dtypes):149 if (not self.is_list_or_tuple(result)150 and not self.is_list_or_tuple(result)151 and not self.is_list_or_tuple(result)152 ): 153 validation.append(self.validate(result, solution, type(solution)))154 elif(self.is_list_or_tuple(result)155 and self.is_list_or_tuple(result)156 and self.is_list_or_tuple(result)157 ):158 validation.append(self.validate_all(results, solutions, type(solution)))159 else:160 raise161 return all(validation)162 def do_test(self, verbose = None):163 if verbose is not None:164 self.verbose = verbose165 166 num_module_to_test = len(self.test_book)167 num_module_pass = 0168 print("Testing EasyOCR: {:d} modules will be tested.\n".format(num_module_to_test))169 for name,tests in self.test_book.items():170 num_test = len(tests)...

Full Screen

Full Screen

exercises.py

Source:exercises.py Github

copy

Full Screen

...33print(is_alphanumeric({'a': 2})) # False34print(is_alphanumeric("this is string....!!!")) # False35#4. Lists & Tuples36print('4. Lists & Tuples')37def is_list_or_tuple(arg):38 if (type(arg) == list or type(arg) == tuple):39 return True40 else:41 return False42print(is_list_or_tuple('hello')) # False43print(is_list_or_tuple(['hello'])) # True44print(is_list_or_tuple([2, {}, 10])) # True45print(is_list_or_tuple({'a': 2})) # False46print(is_list_or_tuple((1, 2))) # True47print(is_list_or_tuple(set())) # False48#5. Same Type49print('5. Same Type')50def are_same_type(arg):51 argtype = ''52 for i in arg:53 if (argtype == ''):54 argtype = type(i)55 elif (argtype != type(i)):56 return False57 return True58print(are_same_type(['hello', 'world', 'long sentence'])) # True59print(are_same_type([1, 2, 9, 10])) # True60print(are_same_type([['hello'], 'hello', ['bye']])) # False61print(are_same_type([['hello'], [1, 2, 3], [{'a': 2}]])) # True...

Full Screen

Full Screen

colors.py

Source:colors.py Github

copy

Full Screen

...11 "sea_green3",12]13def is_dict(obj):14 return isinstance(obj, dict)15def is_list_or_tuple(obj):16 return isinstance(obj, list) or isinstance(obj, tuple)17def is_nested(obj):18 if isinstance(obj, str) or isinstance(obj, int) or isinstance(obj, float):19 return False20 elif is_dict(obj) or is_list_or_tuple(obj):21 return True22 else:23 # defaulting to False for now, so that custom object just gets printed as string24 return False25def populate_tree(node, data, level=1):26 if not is_nested(data):27 node.add(str(data))28 elif "__rich_console__" in dir(data):29 node.add(data)30 elif is_dict(data):31 for k, v in data.items():32 tmp_node = node.add(f"[bold {LEVELS[level]}]{k}[/bold {LEVELS[level]}]")33 populate_tree(tmp_node, v, level + 1)34 # if not is_nested(v):35 # node.add(f"[bold magenta]{k}[/bold magenta] [yellow]──[/yellow] {v}")36 # else:37 # tmp_node = node.add(f"[bold magenta]{k}[/bold magenta]")38 # populate_tree(tmp_node, v)39 elif is_list_or_tuple(data):40 for x in data:41 populate_tree(node, x)42def mate_print(data):43 if is_dict(data):44 console.print()45 data_len = len(data)46 for idx, itm in enumerate(data.items()):47 k, v = itm48 root = Tree(f"[bold {LEVELS[0]}]{k}", guide_style="yellow")49 populate_tree(root, v)50 console.print(root)51 if idx != data_len - 1 and is_nested(v):52 console.print()53 console.print()54 elif is_list_or_tuple(data):55 root = Tree("", guide_style="yellow")56 populate_tree(root, data)57 console.print(root)58 console.print()59 else:60 console.print()61 console.print(data)62 console.print()63def remove_markup_tags(string_with_markups):64 got = re.findall(r"\[([^\[]+?)\]", string_with_markups)65 tmp_str = string_with_markups66 for x in got:67 if not x.startswith("/"):68 y = "/" + x...

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 localstack 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