Best Python code snippet using autotest_python
context.py
Source:context.py
...148 Context.test_fail()149 return150 Context.test_pass()151 @staticmethod152 def test_any(tests):153 for t in tests:154 if t:155 Context.test_pass()156 return157 Context.test_fail()158 159 @staticmethod160 def test_pass():161 stdout.write( '\t{}'.format(1) )162 @staticmethod163 def test_fail():164 stdout.write( '\t{}'.format(0) )165 166 @staticmethod167 def write(line, index, word, args):168 # Variables that we may use as part of other features.169 lemmata = line.get_lemmata(word)170 signs = word.split('-')171 (leftcx, leftlem) = \172 Context.get_left_context(line, index, word, args)173 (leftcx2, leftlem2) = \174 Context.get_left_context(line, index, word, args, offset = 2)175 (rightcx, rightlem) = \176 Context.get_right_context(line, index, word, args)177 # Print raw lemma tag. May include gloss, even when178 # --nogloss switch is provided. This is for the benefit179 # of human readers with some familiarity with Sumerian.180 181 stdout.write( '\t"{}/{}"'.format( word,182 Context.format_context(lemmata) ))183 # Index of word in line. 0-based.184 stdout.write( '\t{}'.format(index) )185 # Left context.186 stdout.write( '\t{}'.format(leftcx) )187 # Right context.188 stdout.write( '\t{}'.format(rightcx) )189 # Print line context.190 stdout.write( '\t"{}"'.format(line.line) )191 # Is word alone on line ?192 Context.test_all([ (leftcx, rightcx) == (None, None) ])193 194 # Left context is dumu.195 Context.test_all([ (leftcx == 'dumu') ])196 # Right context is dumu.197 Context.test_all([ (rightcx == 'dumu') ])198 # ^ ki <word> $199 Context.test_all([ (leftcx2, leftcx, rightcx) == \200 (None, 'ki', None) ])201 202 # ^ igi <word> $203 Context.test_all([ (leftcx2, leftcx, rightcx) == \204 (None, 'igi', None) ])205 # ^ igi <word>-sze $206 Context.test_all([ (leftcx2, leftcx, rightcx) == (None, 'igi', None),207 word.endswith('-sze3') ])208 # Personnenkeil: ^ 1(disz) <word> $209 Context.test_all([ (leftcx2, leftcx, rightcx) == \210 (None, '1(disz)', None) ])211 # ^ kiszib3 <word> $212 Context.test_all([ (leftcx2, leftcx, rightcx) == \213 (None, 'kiszib3', None) ])214 # ^ giri3 <word> $215 Context.test_all([ (leftcx2, leftcx, rightcx) == \216 (None, 'giri3', None) ])217 # First syllable repeated218 if len(signs) > 1:219 Context.test_all([ signs[0] == signs[1] ])220 else:221 Context.test_fail()222 # Last syllable repeated223 signs = word.split('-')224 if len(signs) > 1:225 Context.test_all([ signs[-2] == signs[-1] ])226 else:227 Context.test_fail()228 # Any syllable repeated229 if len(signs) > 1:230 Context.test_any([ a == b for (a, b)231 in zip(signs, signs[1:]) ])232 else:233 Context.test_fail()234 # Is profession235 Context.test_any([ pf == lem236 for pf in Context.professions237 for lem in lemmata ])238 # Contains profession239 Context.test_any([ pf in lem 240 for pf in Context.professions241 for lem in lemmata ])242 # Left context is profession243 if leftlem:244 Context.test_any([ pf == lem245 for pf in Context.professions246 for lem in line.get_lemmata(leftcx) ])247 else:248 Context.test_fail()249 # Left context contains profession250 if leftlem:251 Context.test_any([ pf in lem252 for pf in Context.professions253 for lem in line.get_lemmata(leftcx) ])254 else:255 Context.test_fail()256 # Right context is profession257 if rightlem:258 Context.test_any([ pf == lem259 for pf in Context.professions260 for lem in line.get_lemmata(rightcx) ])261 else:262 Context.test_fail()263 # Right context contains profession264 if rightlem:265 Context.test_any([ pf in lem266 for pf in Context.professions267 for lem in line.get_lemmata(rightcx) ])268 else:269 Context.test_fail()270 # Starts with ur-271 Context.test_all([ word.startswith('ur-') ])272 273 # Starts with lu2-274 Context.test_all([ word.startswith('lu2-') ])275 276 # Ends with -mu277 Context.test_all([ word.endswith('-mu') ])278 279 # Contains {d}280 Context.test_all([ '{d}' in word ])281 # Contains {ki}282 Context.test_all([ '{ki}' in word ])283 # Contains any determinative284 Context.test_all([ '{' in word ])285 # Contains q sound286 Context.test_all([ 'q' in word ])287 # Contains lugal288 Context.test_all([ 'lugal' in word ])289 # Contains numeric elements290 Context.test_any([ '(asz)' in word,291 '(disz)' in word,292 '(u)' in word ])293 # Followed by sag294 Context.test_all([ rightcx == 'sag' ])295 # Followed by zarin296 Context.test_all([ rightcx == 'zarin' ])297 # Preceded by numeric classifier298 Context.test_all([ leftcx in ( 'ba-an', 'ba-ri2-ga', 'bur3', 'da-na',299 'gin2-tur', 'gin2', 'gur-lugal', 300 'gur-sag-gal2', 'gur', 'iku', 'GAN2',301 'ku-li-mu', 'ku-li-kam', 'kusz3',302 'sar', 'sila3' ) ])303 # iti at head of sentence304 Context.test_all([ 'iti' == line.words[0][0] ])...
testingpython.py
Source:testingpython.py
1import collections2def test_any(x):3 if any(x):4 print("hello any")5 if x:6 print("Hello collection")7b = [None, None, None, 1]8c = [None, None, None]9test_any(b)10test_any(c)11my_int = 512print(id(my_int))13d = my_int14print(id(d))15d = 916print(id(d))17cnt = collections.Counter()18my_list = ['red', 'blue', 'green', 'red', 'blue', 'red']19for word in my_list:20 cnt[word] += 121print(cnt)22print(my_list[-1])23print(my_list[-2])24my_dict = {'index': 1, 'timestamp': '2021-04-07 10:10:00', 'proof': 234, 'previous_hash': 'abcdef1234567890'}...
any.py
Source:any.py
1def test_any(iterable):2 for element in iterable:3 if element:4 return True5 return False6print(test_any(['']))...
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!!