How to use get_origin method in SeleniumBase

Best Python code snippet using SeleniumBase

operation.py

Source:operation.py Github

copy

Full Screen

...35 def set_gives(self, name):36 self.gives.append(name)37 def get_gives(self):38 return self.gives39 def get_origin(self):40 return self.origin41 def set_total_gives(self, li):42 self.gives= li43 44 def set_total_origin(self, li):45 self.origin= li46 def set_initia(self):47 self.intia = True48 self.full_string= self.string49 def get_first_word(self):50 for i in range(len(self.string)):51 if(self.string[i]=='.' or self.string[i]==' '):52 return self.string[:i].strip()53 def check_first_word(self):54 #IF the first word is not a channel55 #if(self.string[:7]!='Channel' and self.string[:7]!='channel'):56 if(self.get_first_word()!='Channel' and self.get_first_word()!='channel'):57 self.origin.append([self.get_first_word(), 'P']) 58 #For every case i have checked by compilying the nextflow code for each operator59 #join in the name of the method doesn't reference the join operator but the action of 'joining' channels together60 def check_join(self):61 #================================62 #join/ phase/ cross/ combine63 #================================64 pattern= r'\.\s*(join|phase|cross|combine)\s*\(\s*(\w+)\s*\)'65 for match in re.finditer(pattern, self.string):66 self.origin.append([match.group(2), 'P'])67 #================================68 #merge/ mix/ concat69 #================================70 pattern= r'\.\s*(merge|mix|concat)\s*\((\s*\w+\s*\,\s*(\w+\s*\,\s*)*\w+\s*|\s*(\w+)\s*)\)'71 for match in re.finditer(pattern, self.string):72 temp=match.group(2)73 temp= temp.split(',')74 for t in temp:75 t= t.strip()76 self.origin.append([t, 'P'])77 #================================78 #spread79 #================================80 pattern= r'\.\s*spread\s*\(([\s\w\.(),\"\'\{\}\[\]+-]+)\)'81 for match in re.finditer(pattern, self.string):82 self.origin.append([match.group(1).strip(), 'V'])83 #print(self.origin)84 85 #From the website: "Channels may be created implicitly by the process output(s) declaration or explicitly using the following channel factory methods."86 #Bug Possible here: if there is () in value => il ne le reconnetra pas87 #Another bug if there is () a fromPath or \n88 def check_factory(self):89 #================================90 #of/ from/ value/ fromList91 #================================92 pattern= r'\.\s*(of|from|value|fromList)\s*\(([\s\w\.,;\"\'\{\}\[\]+-]*)\)'93 for match in re.finditer(pattern, self.string):94 #print('test',match.group(1))95 self.origin.append([match.group(2).strip(), 'V'])96 #================================97 #fromPath/ fromFilePairs98 #================================99 pattern= r'.\s*(fromPath|fromFilePairs|watchPath)\s*\(([^\)\n]*)\)'100 for match in re.finditer(pattern, self.string):101 #print('test',match.group(1))102 self.origin.append([match.group(2).strip(), 'A'])103 #================================104 #fromSRA105 #================================106 pattern= r'.\s*fromSRA\s*\(([^\)\n]*)\)'107 for match in re.finditer(pattern, self.string):108 #print('test',match.group(1))109 self.origin.append([match.group(1).strip(), 'S'])110 #================================111 #Bind VERSION1 myChannel.bind( 'Hello world' )112 #================================113 pattern= r'.\s*bind\s*\(([^\)\n]*)\)'114 for match in re.finditer(pattern, self.string):115 #print('test',match.group(2))116 self.origin.append([match.group(1).strip(), 'V'])117 #================================118 #Bind VERSION2 myChannel << 'Hello world'119 #================================ 120 pattern= r'(<<)\s*([^\n]*)'121 #We do this in cas a '<<' is in a mapor another operator122 for match in re.finditer(pattern, self.string):123 i= match.span(1)[0]124 curly, para=0, 0125 while(i<len(self.string)):126 if(self.string[i]=='{' or self.string[i]=='}'):127 curly+=1128 elif(self.string[i]=='(' or self.string[i]==')'):129 para+=1130 i+=1131 if(curly%2==0 and para%2==0):132 #print('test',match.group(1))133 self.origin.append([match.group(2).strip(), 'V'])134 135 136 def check_fork(self):137 #================================138 #choice139 #================================140 pattern= r'\.\s*(choice)\s*\((\s*\w+\s*\,\s*(\w+\s*\,\s*)*\w+\s*|\s*(\w+)\s*)\)'141 for match in re.finditer(pattern, self.string):142 temp=match.group(2)143 temp= temp.split(',')144 for t in temp:145 t= t.strip()146 self.gives.append([t, 'P'])147 #================================148 #into VERSION 1149 #================================150 pattern= r'\.\s*(into)\s*\{(\s*\w+\s*\;\s*(\w+\s*\;\s*)*\w*\s*|\s*(\w+)\s*)\}'151 for match in re.finditer(pattern, self.string):152 temp=match.group(2)153 temp= temp.split(';')154 for t in temp:155 t= t.strip()156 self.gives.append([t, 'P'])157 #================================158 #into VERSION 2159 #================================160 #For the case (foo, bar) = Channel.from( 'a','b','c').into(2)161 #We don't have to worry about the (foo, bar) because that is already delt with in the extract_channels method 162 pattern= r'\.\s*(into)\s*\(\s*(\d+)\s*\)'163 for match in re.finditer(pattern, self.string):164 nb= int(match.group(2))165 #================================166 #seperate 167 #================================168 pattern= r'\.\s*(separate)\s*\((\s*\w+\s*\,\s*(\w+\s*\,\s*)*\w+\s*|\s*(\w+)\s*)\)'169 for match in re.finditer(pattern, self.string):170 #For the case (queue1, queue2, queue3) = source.separate(3) { a -> [a, a+1, a*a] }171 #We don't have to worry about the (queue1, queue2, queue3) because that is already delt with in the extract_channels method 172 try:173 nb= int(match.group(2))174 #print(nb)175 except:176 temp=match.group(2)177 temp= temp.split(',')178 for t in temp:179 t= t.strip()180 self.gives.append([t, 'P'])181 #================================182 #tap VERSION1 ()183 #================================184 #pattern= r'\.\s*tap\s*\(\s*(\w+)\s*\)|\.\s*tap\s*\{\s*(\w+)\s*\}'185 pattern= r'\.\s*tap\s*\(\s*(\w+)\s*\)'186 for match in re.finditer(pattern, self.string):187 #print(match.group(1))188 self.gives.append([match.group(1), 'P'])189 #================================190 #tap VERSION2 {}191 #================================192 pattern= r'\.\s*tap\s*\{\s*(\w+)\s*\}'193 for match in re.finditer(pattern, self.string):194 #print(match.group(1))195 self.gives.append([match.group(1), 'P'])196 197 def check_set(self):198 pattern= r'\.\s*set\s*{\s*(\w+)\s*}'199 for match in re.finditer(pattern, self.string):200 self.gives.append([match.group(1), 'P'])201 def extract_affectation(self):202 pattern= r'(\w+) *= *(\w+)'203 for match in re.finditer(pattern, self.string):204 self.gives.append([match.group(1), 'P'])205 self.origin.append([match.group(2), 'P'])206 def check_same_value(self):207 tab_to_remove=[]208 for o in self.origin:209 for g in self.gives:210 if(o[0]==g[0]):211 tab_to_remove.append(o)212 print(self.origin)213 for t in tab_to_remove:214 self.origin= self.origin.remove(t)215 print(self.origin)216 217 #Sometimes users modify a channel such as c.map{...}.set(c)218 #Creates a loop because c is in the origin and gives -> we want to remove this 219 #Channels shoudn't be able to be modified220 #So we raise an error221 def check_gives_origin(self):222 if(self.full_string==None):223 self.full_string = self.string224 for o in self.origin:225 if o in self.gives:226 raise Exception(f'"{o[0]}" was found in the origin and gives of the operartion "{self.full_string}" 6')227 228 def initialise_operation(self):229 if(not self.intia):230 self.string= self.string.strip()231 if(self.full_string==None):232 self.set_full_string(self.string)233 if(self.normal):234 self.check_first_word()235 self.check_set()236 self.check_join()237 self.check_fork()238 self.check_factory()239 else:240 self.extract_affectation()241 self.check_gives_origin()242 self.intia=True243 #self.check_same_value()244 #DO_STUFF245 def tests(self):246 #Channel.join(..) or others shoudn't work but we've added it anyway247 #It doesn't matter since we suppose that the workflow is written correctly248 #===================================================249 #join250 #===================================================251 test="left.join(right).view()"252 c= Operation('penguin', test)253 c.initialise_operation()254 assert(c.get_origin()==[['left', 'P'], ['right', 'P']])255 test="Channel.join(right).view()"256 c= Operation('penguin', test)257 c.initialise_operation()258 assert(c.get_origin()==[['right', 'P']])259 #===================================================260 #merge261 #===================================================262 test="odds.merge( evens ).view()"263 c= Operation('penguin', test)264 c.initialise_operation()265 assert(c.get_origin()==[['odds', 'P'], ['evens', 'P']])266 test="odds.merge( evens, george, and,the , penguin ).view()"267 c= Operation('penguin', test)268 c.initialise_operation()269 assert(c.get_origin()==[['odds', 'P'], ['evens', 'P'], ['george', 'P'], ['and', 'P'], ['the', 'P'], ['penguin', 'P']])270 test="Channel.merge(right).view()"271 c= Operation('penguin', test)272 c.initialise_operation()273 assert(c.get_origin()==[['right', 'P']])274 #===================================================275 #mix276 #===================================================277 test="odds.mix( evens ).view()"278 c= Operation('penguin', test)279 c.initialise_operation()280 assert(c.get_origin()==[['odds', 'P'], ['evens', 'P']])281 test="odds.mix ( evens, george, and,the , penguin ).view()"282 c= Operation('penguin', test)283 c.initialise_operation()284 assert(c.get_origin()==[['odds', 'P'], ['evens', 'P'], ['george', 'P'], ['and', 'P'], ['the', 'P'], ['penguin', 'P']])285 test="Channel.mix(right).view()"286 c= Operation('penguin', test)287 c.initialise_operation()288 assert(c.get_origin()==[['right', 'P']])289 #===================================================290 #phase291 #===================================================292 test="left.phase (right).view()"293 c= Operation('penguin', test)294 c.initialise_operation()295 assert(c.get_origin()==[['left', 'P'], ['right', 'P']])296 test="Channel.phase(right).view()"297 c= Operation('penguin', test)298 c.initialise_operation()299 assert(c.get_origin()==[['right', 'P']])300 #===================================================301 #cross302 #===================================================303 test="left.cross (right).view()"304 c= Operation('penguin', test)305 c.initialise_operation()306 assert(c.get_origin()==[['left', 'P'], ['right', 'P']])307 test="Channel.cross(right).view()"308 c= Operation('penguin', test)309 c.initialise_operation()310 assert(c.get_origin()==[['right', 'P']])311 #===================================================312 #cross313 #===================================================314 test="left.combine (right).view()"315 c= Operation('penguin', test)316 c.initialise_operation()317 assert(c.get_origin()==[['left', 'P'], ['right', 'P']])318 test="Channel.combine(right).view()"319 c= Operation('penguin', test)320 c.initialise_operation()321 assert(c.get_origin()==[['right', 'P']])322 #===================================================323 #mix324 #===================================================325 test="odds.concat( evens ).view()"326 c= Operation('penguin', test)327 c.initialise_operation()328 assert(c.get_origin()==[['odds', 'P'], ['evens', 'P']])329 test="odds.concat ( evens, george, and,the , penguin ).view()"330 c= Operation('penguin', test)331 c.initialise_operation()332 assert(c.get_origin()==[['odds', 'P'], ['evens', 'P'], ['george', 'P'], ['and', 'P'], ['the', 'P'], ['penguin', 'P']])333 test="Channel.concat(right).view()"334 c= Operation('penguin', test)335 c.initialise_operation()336 assert(c.get_origin()==[['right', 'P']])337 #===================================================338 #spread339 #===================================================340 test="Channel.from(1,2,3).spread(['a','b'])"341 c= Operation('penguin', test)342 c.initialise_operation()343 assert(c.get_origin()==[["['a','b']", 'V'], ["1,2,3", 'V']])344 #===================================================345 #choice346 #===================================================347 test="source.choice( queue1, queue2 ) { a -> a =~ /^Hello.*/ ? 0 : 1 }"348 c= Operation('penguin', test)349 c.initialise_operation()350 assert(c.get_origin()==[['source', 'P']])351 assert(c.get_gives()==[['queue1', 'P'], ['queue2', 'P']])352 test="Channel.choice( queue1, queue2 ) { a -> a =~ /^Hello.*/ ? 0 : 1 }"353 c= Operation('penguin', test)354 c.initialise_operation()355 assert(c.get_origin()==[])356 assert(c.get_gives()==[['queue1', 'P'], ['queue2', 'P']])357 test="source.choice( queue1, queue2 , queue3) { a -> a =~ /^Hello.*/ ? 0 : 1 }"358 c= Operation('penguin', test)359 c.initialise_operation()360 assert(c.get_origin()==[['source', 'P']])361 assert(c.get_gives()==[['queue1', 'P'], ['queue2', 'P'], ['queue3', 'P']])362 #===================================================363 #into364 #===================================================365 test="Channel.from( 'a', 'b', 'c' ).into{ foo; bar }"366 c= Operation('penguin', test)367 c.initialise_operation()368 assert(c.get_gives()==[['foo', 'P'], ['bar', 'P']])369 assert(c.get_origin()==[["'a', 'b', 'c'", 'V']])370 test="Channel.from( 'a','b','c').into(2)"371 c= Operation('penguin', test)372 c.initialise_operation()373 assert(c.get_gives()==[])374 assert(c.get_origin()==[["'a','b','c'", 'V']])375 #===================================================376 #seperate377 #===================================================378 test="Channel.from ( 2,4,8 ).separate( queue1, queue2 ) { a -> [a+1, a*a] }"379 c= Operation('penguin', test)380 c.initialise_operation()381 assert(c.get_gives()==[['queue1', 'P'], ['queue2', 'P']])382 assert(c.get_origin()==[["2,4,8", 'V']])383 test="source.separate(3) { a -> [a, a+1, a*a] }"384 c= Operation('penguin', test)385 c.initialise_operation()386 assert(c.get_origin()==[['source', 'P']])387 assert(c.get_gives()==[])388 #===================================================389 #tap390 #===================================================391 test="Channel.of ( 'a', 'b', 'c' ).tap ( log1 ).map { it * 2 }.tap ( log2 ).map { it.toUpperCase() }.view { 'Result: $it' }"392 c= Operation('penguin', test)393 c.initialise_operation()394 #print(c.get_gives())395 assert(c.get_gives()==[['log1', 'P'], ['log2', 'P']])396 test="Channel.of ( 'a', 'b', 'c' ).tap { log1 }.map { it * 2 }.tap { log2 }.map { it.toUpperCase() }.view { 'Result: $it' }"397 c= Operation('penguin', test)398 c.initialise_operation()399 #print(c.get_gives())400 assert(c.get_gives()==[['log1', 'P'], ['log2', 'P']])401 #===================================================402 #of403 #===================================================404 test="Channel.of(1, 4, 6, 7, 8)"405 c= Operation('penguin', test)406 c.initialise_operation()407 assert(c.get_origin()==[['1, 4, 6, 7, 8', 'V']])408 #===================================================409 #value410 #===================================================411 test="Channel.value()"412 c= Operation('penguin', test)413 c.initialise_operation()414 assert(c.get_origin()==[['', 'V']])415 test="Channel.value( 'Hello there' )"416 c= Operation('penguin', test)417 c.initialise_operation()418 assert(c.get_origin()==[["'Hello there'", 'V']])419 test="Channel.value( [1,2,3,4,5] )"420 c= Operation('penguin', test)421 c.initialise_operation()422 assert(c.get_origin()==[['[1,2,3,4,5]', 'V']])423 #===================================================424 #fromList425 #===================================================426 test="Channel.fromList( ['a', 'b', 'c', 'd'] ).view { 'value: $it' }"427 c= Operation('penguin', test)428 c.initialise_operation()429 assert(c.get_origin()==[["['a', 'b', 'c', 'd']", 'V']])430 #===================================================431 #fromPath432 #===================================================433 test="Channel.fromPath( '/data/some/bigfile.txt' )"434 c= Operation('penguin', test)435 c.initialise_operation()436 assert(c.get_origin()==[["'/data/some/bigfile.txt'", 'A']])437 test="Channel.fromPath( '/data/big/*.txt' )"438 c= Operation('penguin', test)439 c.initialise_operation()440 assert(c.get_origin()==[["'/data/big/*.txt'", 'A']])441 test="Channel.fromPath( 'data/file_{1,2}.fq' )"442 c= Operation('penguin', test)443 c.initialise_operation()444 assert(c.get_origin()==[["'data/file_{1,2}.fq'", 'A']])445 test="Channel.fromPath( ['/some/path/*.fq', '/other/path/*.fastq'] )"446 c= Operation('penguin', test)447 c.initialise_operation()448 assert(c.get_origin()==[["['/some/path/*.fq', '/other/path/*.fastq']", 'A']])449 #===================================================450 #fromFilePairs451 #===================================================452 test="Channel.fromFilePairs('/my/data/SRR*_{1,2}.fastq')"453 c= Operation('penguin', test)454 c.initialise_operation()455 assert(c.get_origin()==[["'/my/data/SRR*_{1,2}.fastq'", 'A']])456 test="Channel.fromFilePairs('/some/data/*', size: -1) { file -> file.extension }"457 c= Operation('penguin', test)458 c.initialise_operation()459 assert(c.get_origin()==[["'/some/data/*', size: -1", 'A']])460 #===================================================461 #fromSRA462 #===================================================463 test="Channel.fromSRA('SRP043510').view()"464 c= Operation('penguin', test)465 c.initialise_operation()466 assert(c.get_origin()==[["'SRP043510'", 'S']])467 test="Channel.fromSRA(ids).view()"468 c= Operation('penguin', test)469 c.initialise_operation()470 assert(c.get_origin()==[["ids", 'S']])471 #===================================================472 #watchPath473 #===================================================474 test="Channel.watchPath( '/path/*.fa' ).subscribe { println 'Fasta file: $it' }"475 c= Operation('penguin', test)476 c.initialise_operation()477 assert(c.get_origin()==[["'/path/*.fa'", 'A']])478 #===================================================479 #Bind480 #===================================================481 test="Channel.bind( 'Hello world' )"482 c= Operation('penguin', test)483 c.initialise_operation()484 #print(c.get_origin())485 assert(c.get_origin()==[["'Hello world'", 'V']])486 test="Channel << 'Hello world' "487 c= Operation('penguin', test)488 c.initialise_operation()489 #print(c.get_origin())490 assert(c.get_origin()==[["'Hello world'", 'V']])491 test="my_channel << 'Hello world' "492 c= Operation('penguin', test)493 c.initialise_operation()494 #print(c.get_origin())495 assert(c.get_origin()==[["my_channel", 'P'], ["'Hello world'", 'V']])496 ...

Full Screen

Full Screen

compat.py

Source:compat.py Github

copy

Full Screen

...8from typing import Any, Generic, Tuple, _GenericAlias9try:10 from typing import get_origin11except ImportError:12 def get_origin(tp) -> Any:13 """Get the unsubscripted version of a type.14 This supports generic types, Callable, Tuple, Union, Literal, Final and ClassVar.15 Return None for unsupported types. Examples::16 get_origin(Literal[42]) is Literal17 get_origin(int) is None18 get_origin(ClassVar[int]) is ClassVar19 get_origin(Generic) is Generic20 get_origin(Generic[T]) is Generic21 get_origin(Union[T, int]) is Union22 get_origin(List[Tuple[T, T]][int]) == list23 """24 if isinstance(tp, _GenericAlias):25 return tp.__origin__26 if tp is Generic:27 return Generic28 return None29try:30 from typing import get_args # lgtm[py/unused-import]31except ImportError:32 def get_args(tp) -> Tuple[Any, ...]:33 """Get type arguments with all substitutions performed.34 For unions, basic simplifications used by Union constructor are performed.35 Examples::36 get_args(Dict[str, int]) == (str, int)37 get_args(int) == ()38 get_args(Union[int, Union[T, int], str][int]) == (int, str)39 get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])40 get_args(Callable[[], T][int]) == ([], int)41 """42 if isinstance(tp, _GenericAlias):43 res = tp.__args__44 if get_origin(tp) is collections.abc.Callable and res[0] is not Ellipsis:45 res = (list(res[:-1]), res[-1])46 return res...

Full Screen

Full Screen

test_origin_type.py

Source:test_origin_type.py Github

copy

Full Screen

...13 self.assertEqual(origin.http_port, http_port)14 self.assertEqual(origin.https_port, https_port)15 def test_origin_type_just_domain(self):16 values = ['www.domain.com']17 self._check_values(self.subject.get_origin(values, None), values[0], 80, 443)18 def test_origin_type_with_http_port(self):19 values = ['www.domain.com', 300]20 self._check_values(self.subject.get_origin(values, None), values[0], 300, 443)21 def test_origin_type_with_http_and_https_port(self):22 values = ['www.domain.com', 300, 5000]23 self._check_values(self.subject.get_origin(values, None), values[0], 300, 5000)24 def test_origin_too_many_values(self):25 values = ['www.domain.com', 300, 5000, 'bad']26 with self.assertRaises(argparse.ArgumentError):27 self.subject.get_origin(values, None)28 def test_origin_too_few_values(self):29 values = []30 with self.assertRaises(argparse.ArgumentError):...

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