How to use _wait method in tox

Best Python code snippet using tox_python

machine.py

Source:machine.py Github

copy

Full Screen

...74 self.write("\n")75 #self._read_view()76 #self._read_view()77 #self._read_view()78 def _wait(self):79 self.moves += 180 self.write(self.state['wait'])81 self.write("\n")82 #self._read_view()83 def _getMenuInstruction(self):84 menu_hdr = "Menu\n"85 self.read(delim="\n", expect=menu_hdr)86 line = "-----\n"87 self.read(delim="\n", expect=line)88 self.read(length=13, assign=self.state['play'])89 self.read(length=20, assign=self.state['instructions'])90 self.read(length=15, assign=self.state['highScore'])91 self.read(length=13, assign=self.state['quit'])92 def _getGameDescription(self):93 self.write(self.state['instructions'])94 self.write("\n")95 game_menu_hdr = "Game moves\n"96 self.read(delim="\n", expect=game_menu_hdr)97 line = "----------\n"98 self.read(delim="\n", expect=line)99 self.read(length=8, assign=self.state['left'])100 self.read(length=9, assign=self.state['right'])101 self.read(length=8, assign=self.state['jump'])102 self.read(length=13, assign=self.state['jumpleft'])103 self.read(length=14, assign=self.state['jumpright'])104 self.read(length=8, assign=self.state['wait'])105 self.read(length=13, assign=self.state['quit'])106 def _rightWin(self):107 length = random.randint(5,20)108 name = ''.join(random.choice(string.ascii_letters) for _ in range(length))109 eip = 'AAAA'110 ebp = 'BBBB'111 sled = '0'*42112 #name = sled + ebp + eip113 win_pcre = r'You found the treasure at position x:([0-9]*) y:([0-9]*) after ([0-9]*) moves\n'114 self.user_id += 1115 varname = "user"+str(self.user_id)116 win = Variable(varname)117 win.set_re(win_pcre, group=3)118 self.write(self.state['right'])119 self.write("\n")120 self.read(delim="\n", assign=win)121 move_pcre = r'Move list: (.*)\n'122 self.read(delim="\n", expect=move_pcre, expect_format='pcre')123 get_name_msg = "Please enter your name: "124 self.read(length=len(get_name_msg), expect=get_name_msg)125 self.highScores.append(dict(name=name, score=win))126 self.write(name+"\n")127 #self.write(sled)128 #self.write(ebp)129 #self.write(eip)130 def _diedBat(self):131 died_pcre = r'You were killed by a bat at position x:([0-9]*) y:([0-9]*) after ([0-9]*) moves\n'132 self.read(delim="\n", expect=died_pcre, expect_format='pcre')133 def _diedZombie(self):134 died_pcre = r'You were killed by a zombie at position x:([0-9]*) y:([0-9]*) after ([0-9]*) moves\n'135 self.read(delim="\n", expect=died_pcre, expect_format='pcre')136 def start(self):137 #self.delay(100)138 self.magic_idx = 0139 self.user_id = 0140 self.highScores = []141 self.highScores.append(dict(name=self._getRandomName(), score=600))142 self.highScores.append(dict(name=self._getRandomName(), score=601))143 self.highScores.append(dict(name=self._getRandomName(), score=999999))144 play_re = "Play game: (.*)\n"145 play = Variable('play')146 play.set_re(play_re, group=1)147 self.state['play'] = play148 instructions_re = "Get instructions: (.*)\n"149 instructions = Variable('instructions')150 instructions.set_re(instructions_re, group=1)151 self.state['instructions'] = instructions152 scores_re = "High Scores: (.*)\n"153 scores = Variable('highScore')154 scores.set_re(scores_re, group=1)155 self.state['highScore'] = scores156 quit_re = "Quit game: (.*)\n"157 quit = Variable('quit')158 quit.set_re(quit_re, group=1)159 self.state['quit'] = quit160 left_re = "Left: (.*)\n"161 left = Variable('left')162 left.set_re(left_re, group=1)163 self.state['left'] = left164 right_re = "Right: (.*)\n"165 right = Variable('right')166 right.set_re(right_re, group=1)167 self.state['right'] = right168 jump_re = "Jump: (.*)\n"169 jump = Variable('jump')170 jump.set_re(jump_re, group=1)171 self.state['jump'] = jump172 jumpleft_re = "Jump Left: (.*)\n"173 jumpleft = Variable('jumpleft')174 jumpleft.set_re(jumpleft_re, group=1)175 self.state['jumpleft'] = jumpleft176 jumpright_re = "Jump Right: (.*)\n"177 jumpright = Variable('jumpright')178 jumpright.set_re(jumpright_re, group=1)179 self.state['jumpright'] = jumpright180 wait_re = "Wait: (.*)\n"181 wait = Variable('wait')182 wait.set_re(wait_re, group=1)183 self.state['wait'] = wait184 self._getMenuInstruction()185 self._firstScores()186 self.menu()187 def menu(self):188 self._getMenuInstruction()189 def instructions(self):190 self._getGameDescription()191 self._getMenuInstruction()192 def play(self):193 self.VIEW_HEIGHT = 13194 self.VIEW_WIDTH = 25195 self.SECRET_NUM = 600196 self.moves = 0197 self.write(self.state['play'])198 self.write("\n")199 #self._read_view()200 #descend stairs201 self._move_right()202 self._move_right()203 self._move_right()204 self._move_right()205 self._move_right()206 #get to end207 self._jumpRight()208 self._jumpRight()209 self._jumpRight()210 self._jumpRight()211 #setup next room choice212 for _ in range(37):213 self._wait()214 def start2zombie(self):215 self._jumpLeft()216 self._jumpLeft()217 self._jumpLeft()218 self._diedZombie()219 def start2bat(self):220 self._jumpLeft()221 self._jumpLeft()222 self._move_left()223 for _ in range(3):224 self._wait()225 self._jumpRight()226 self._jumpLeft()227 self._jumpLeft()228 self._jumpLeft()229 self._jumpLeft()230 self._jumpLeft()231 self._jumpLeft() 232 self._move_right()233 self._wait()234 self._wait()235 self._wait()236 self._diedBat()237 def start2first(self):238 #choose first239 self._move_left()240 #get to first241 self._jumpRight()242 self._move_right()243 self._move_right()244 self._move_right()245 self._jumpRight()246 self._jumpRight()247 self._jumpRight()248 self._move_right()249 self._jumpRight()250 self._move_right()251 self._move_right()252 #setup next room choice253 for _ in range(40):254 self._wait()255 def first2first(self):256 #choose first257 self._move_left()258 #get to finish259 self._jumpRight()260 self._wait()261 self._jumpRight()262 self._move_right()263 self._move_right()264 self._move_right()265 self._move_right()266 self._move_right()267 self._jumpRight()268 self._jumpRight()269 self._jumpRight()270 self._move_right()271 self._jumpRight()272 self._move_right()273 self._move_right()274 #setup next room choice275 self._wait()276 self._wait()277 self._wait()278 self._wait()279 self._wait()280 self._wait()281 self._wait()282 self._wait()283 self._wait()284 for _ in range(24):285 self._wait()286 def first2second(self):287 #choose second288 self._move_right()289 #get to second290 self._jumpRight()291 self._wait()292 self._jumpRight()293 self._move_right()294 self._move_right()295 self._move_right()296 self._move_right()297 self._move_right()298 self._move_right()299 self._move_right()300 self._move_right()301 self._move_right()302 self._move_right()303 self._move_right()304 self._wait()305 self._wait()306 self._wait()307 self._wait()308 self._wait()309 self._wait()310 self._wait()311 self._wait()312 self._wait()313 self._wait()314 self._move_right()315 self._jumpLeft()316 self._move_left()317 self._move_left()318 self._jumpRight()319 self._move_right()320 for _ in range(24):321 self._wait()322 def start2second(self):323 #choose second324 self._move_right()325 326 #get to finish327 self._move_right()328 self._move_right()329 self._move_right()330 self._move_right()331 self._move_right()332 self._move_right()333 self._move_right()334 self._move_right()335 self._move_right()336 self._move_right()337 self._move_right()338 self._move_right()339 self._jumpLeft()340 self._move_left()341 self._jumpLeft()342 self._move_left()343 self._jumpLeft()344 #setup next room choice345 self._wait()346 self._wait()347 self._wait()348 self._wait()349 self._wait()350 self._wait()351 self._wait()352 self._wait()353 self._wait()354 self._wait()355 self._wait()356 self._jumpRight()357 self._jumpRight()358 self._move_right()359 self._wait()360 for _ in range(24):361 self._wait()362 def second2first(self):363 #choose first364 self._move_left()365 #get to first366 self._move_right()367 self._move_right()368 self._move_right()369 self._move_right()370 self._move_right()371 self._move_right()372 self._move_right()373 self._jumpRight()374 self._wait()375 self._wait()376 self._wait()377 self._jumpRight()378 self._move_right()379 self._move_right()380 self._move_right()381 self._jumpRight()382 self._jumpRight()383 self._jumpRight()384 self._move_right()385 self._jumpRight()386 self._move_right()387 self._move_right()388 #setup next room choice389 self._wait()390 for _ in range(24):391 self._wait()392 def second2second(self):393 #choose second394 self._move_right()395 #get to finish396 self._move_right()397 self._move_right()398 self._move_right()399 self._move_right()400 self._move_right()401 self._move_right()402 self._jumpRight()403 self._wait()404 self._wait()405 self._wait()406 self._wait()407 self._wait()408 self._jumpRight()409 self._move_right()410 self._move_right()411 self._move_right()412 self._move_right()413 self._move_right()414 self._move_right()415 self._move_right()416 self._move_right()417 self._move_right()418 self._move_right()419 self._move_right()420 self._jumpLeft()421 self._move_left()422 self._move_left()423 self._jumpRight()424 self._move_right()425 for _ in range(24):426 self._wait()427 def start2last(self):428 #choose last429 self._wait()430 #move to treasure431 self._move_right()432 self._move_right()433 self._wait()434 self._move_right()435 self._jumpRight()436 self._jumpRight()437 self._jumpRight()438 self._jumpRight()439 self._wait()440 self._jumpRight()441 self._jumpRight()442 self._jumpRight()443 self._jumpRight()444 self._move_right()445 self._rightWin()446 def first2last(self):447 while(self.moves < self.SECRET_NUM):448 self.first2first()449 #choose last450 self._wait()451 #move to door452 self._jumpRight()453 self._wait()454 self._jumpRight()455 #move to treasure456 self._move_right()457 self._move_right()458 self._jumpRight()459 self._jumpRight()460 self._jumpRight()461 self._jumpRight()462 self._wait()463 self._wait()464 self._wait()465 self._wait()466 self._wait()467 self._wait()468 self._wait()469 self._jumpRight()470 self._jumpRight()471 self._jumpRight()472 self._wait()473 self._wait()474 self._jumpRight()475 self._move_right()476 self._rightWin()477 def second2last(self):478 while(self.moves < self.SECRET_NUM):479 self.second2second()480 #choose last481 self._wait()482 #move to door483 self._move_right()484 self._move_right()485 self._move_right()486 self._move_right()487 self._move_right()488 self._move_right()489 self._jumpRight()490 self._wait()491 self._wait()492 self._wait()493 self._wait()494 self._wait()495 self._jumpRight()496 #move to treasure497 self._move_right()498 self._move_right()499 self._jumpRight()500 self._jumpRight()501 self._jumpRight()502 self._jumpRight()503 self._wait()504 self._jumpRight()505 self._jumpRight()506 self._jumpRight()507 self._jumpRight()508 self._move_right()509 self._rightWin()510 def _firstScores(self):511 self.write(self.state['highScore'])512 self.write("\n")513 #if len(self.highScores) == 0:514 # no_scores_msg = "NO HIGH SCORES!\n"515 # self.read(delim="\n", expect=no_scores_msg)516 #else:517 top_score_msg = "Dungeon conquered in " + str(self.highScores[0]['score']) + " moves " + self.highScores[0]['name'] + "\n"518 self.read(delim="\n", expect=top_score_msg)519 line_msg = "-------------------\n"520 self.read(delim="\n", expect=line_msg)521 title_msg = " moves | name \n"522 self.read(delim="\n", expect=title_msg)523 self.read(delim="\n", expect=line_msg)524 #score_pcre = r'([0-9]*). ([0-9]*) (.*)\n'525 #self.read(delim="\n", expect=score_pcre, expect_format='pcre')526 #self.read(delim="\n", expect=score_pcre, expect_format='pcre')527 for index,score in enumerate(self.highScores[1:]):528 score_msg = str(index+2) + ". " + str(score['score']) + " " + score['name'] + "\n"529 self.read(delim="\n", expect=score_msg)530 def scores(self):531 self.write(self.state['highScore'])532 self.write("\n")533 #if len(self.highScores) == 0:534 # no_scores_msg = "NO HIGH SCORES!\n"535 # self.read(delim="\n", expect=no_scores_msg)536 #else:537 top_score_msg = r'Dungeon conquered in ([0-9]*) moves (.*)\n'538 self.read(delim="\n", expect=top_score_msg, expect_format='pcre')539 line_msg = "-------------------\n"540 self.read(delim="\n", expect=line_msg)541 title_msg = " moves | name \n"542 self.read(delim="\n", expect=title_msg)543 self.read(delim="\n", expect=line_msg)544 score_pcre = r'([0-9]*). ([0-9]*) (.*)\n'545 self.read(delim="\n", expect=score_pcre, expect_format='pcre')546 self.read(delim="\n", expect=score_pcre, expect_format='pcre')547 for _ in self.highScores[3:]:548 self.read(delim="\n", expect=score_pcre, expect_format='pcre')549 def attack1(self):550 self.VIEW_HEIGHT = 13551 self.VIEW_WIDTH = 25552 self.write(self.state['play'])553 self.write("\n")554 for _ in range(64):555 self._move_left()556 for _ in range(64):557 self._move_left()558 self._move_right()559 self._move_right()560 self._move_right()561 self._move_right()562 self._move_right()563 self._move_right()564 self._jumpRight()565 self._jumpRight()566 self._jumpRight()567 self._jumpRight()568 self._move_right()569 self._move_right()570 self._move_right()571 self._move_right()572 self._jumpRight()573 self._jumpRight()574 self._jumpRight()575 self._move_right()576 self._jumpRight()577 self._move_right()578 self._move_right()579 self._jumpRight()580 self._wait()581 self._wait()582 self._jumpRight()583 self._move_right()584 self._move_right()585 self._move_right()586 self._move_right()587 self._jumpRight()588 self._jumpRight()589 self._jumpRight()590 self._move_right()591 self._jumpRight()592 self._move_right()593 self._move_right()594 self._jumpRight()595 for _ in range(12):596 self._wait()597 self._jumpRight()598 for _ in range(8):599 self._move_right()600 self._move_left()601 self._move_left()602 self._move_left()603 self._wait()604 self._wait()605 self._wait()606 self._jump() 607 self._move_right()608 self._wait()609 self._wait()610 self._jumpRight()611 self._move_right()612 self._move_right()613 self._move_right()614 self._jumpLeft()615 self._move_left()616 self._jumpLeft()617 self._jumpRight()618 for _ in range(7):619 self._move_right()620 self._jumpRight()621 for _ in range(8):622 self._wait()623 self._jumpRight()624 self._move_right()625 self._move_right()626 self._move_right()627 self._jumpRight()628 self._jumpRight()629 self._jumpRight() 630 self._move_right()631 for _ in range(27):632 self._wait() 633 self._jumpRight()634 self._move_right()635 self._move_right()636 self._jumpRight()637 for _ in range(15):638 self._wait()639 self._jumpRight()640 self._move_right()641 self._move_right()642 self._wait()643 self._wait()644 self._wait()645 self._wait()646 self._move_right() 647 self._jumpRight()648 self._jumpRight()649 self._wait()650 self._wait()651 self._wait()652 self._jumpRight()653 self._jumpRight()654 self._wait()655 self._wait()656 self._wait()657 self._wait()658 self._wait()659 self._jumpRight()660 self._jumpRight()661 self._jumpRight()662 self._jumpRight()663 self._move_right()664 self.write(self.state['right'])665 self.write("\n")666 self.read(delim="\n", assign=self.state['win'])667 first_pcre = r'Move list: (.{512})'668 flag_pcre = r'(.{40})'669 last_pcre = r'(.*)\n'670 flag = Variable('flag')671 flag.set_re(flag_pcre, group=1)672 self.state['flag'] = flag...

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