How to use del_cell method in avocado

Best Python code snippet using avocado_python

test_combinationRow.py

Source:test_combinationRow.py Github

copy

Full Screen

...83 self.assertEqual(self.row.hash_table[(0, 1)], 0, "completely_uncover don't uncover value")84 self.assertEqual(self.row.hash_table[(0, 2)], None, "completely_uncover change disabled value")85 # Tests of del_cell function86 def test_del_cell_uncovered_value(self):87 self.assertEqual(self.row.del_cell((0, 0)), -1, "del_cell return wrong values")88 self.assertEqual(self.row.uncovered, 11, "del_cell create wrong uncovered value")89 self.assertEqual(self.row.covered_more_than_ones, 0, "del_cell create wrong covered_more_than_ones value")90 self.assertEqual(self.row.hash_table[(0, 0)], None, "del_cell don't disable value")91 def test_del_cell_disabled_value(self):92 self.row.hash_table[(0, 0)] = None93 self.row.uncovered = 1194 self.assertEqual(self.row.del_cell((0, 0)), 0, "del_cell return wrong values")95 self.assertEqual(self.row.uncovered, 11, "del_cell create wrong uncovered value")96 self.assertEqual(self.row.covered_more_than_ones, 0, "del_cell create wrong covered_more_than_ones value")97 self.assertEqual(self.row.hash_table[(0, 0)], None, "del_cell don't disable value")98 # Tests of is_valid function99 def test_is_valid_valid(self):100 self.assertEqual(self.row.is_valid((0, 0)), True, "is_valid return wrong values")101 def test_is_valid_invalid(self):102 self.row.hash_table[(0, 0)] = None103 self.assertEqual(self.row.is_valid((0, 0)), False, "is_valid return wrong values")104 # Test of get_all_uncovered_combinations function105 def test_get_all_uncovered_combinations(self):106 self.row.hash_table[(0, 0)] = None107 self.row.hash_table[(0, 1)] = 1108 self.row.hash_table[(0, 2)] = 2...

Full Screen

Full Screen

GAME.py

Source:GAME.py Github

copy

Full Screen

1# Copyright (c) Durbich2# Licensed under the MIT License. See LICENSE file for license information.345from configparser import ConfigParser6from threading import Thread7import random8import time9import os1011import control12import snake13import field141516# before draw a new frame we need to erase old, but comand depends on OS17screen_clear_comand = 'cls' if os.name == 'nt' else 'clear'1819config = ConfigParser()20config.read('game_data.cfg')21highscore = int(config['player']['highscore'])22x, y = int(config['field']['x']), int(config['field']['y'])23bounds_around = True if config['field']['bounds_around'] == 'yes' else False2425room_size = (x, y)26room = field.Field(room_size, bounds_around)27player = snake.Snake(room_size)28room.snake_draw(player.body)29room.spawn_food()30keypress = control.Control()31key_daemon = Thread(target=keypress.key_wait, daemon=True)32key_daemon.start()333435def make_next_frame():36 # Let's update snake and super_food if is37 player.move()38 del_cell = player.check_released_cell()39 if del_cell:40 room.clear_cell(del_cell)41 if room.super_food_x_y:42 room.update_super_food()43 # checking for collision44 head = player.body[0]45 where_is_head = room.head_in_cell_out(head)46 if where_is_head == 'bound':47 player.die('wall bump')48 if where_is_head == 'food':49 player.food_eating()50 need_super_food = (player.length-4) % 5 == 051 room.spawn_food(super_food=need_super_food)52 if need_super_food:53 room.update_super_food()54 if where_is_head == 'super food':55 player.food_eating(room.super_food_score)56 if player.is_dead:57 room.cells[head[1]][head[0]] = 'FF'58 if room.is_have_emptycell is False:59 player.die('There is no space for me in this world')60 os.system(screen_clear_comand) # erase old screen61 room.framebuild()626364dir_dict = {'w': 'U', 'a': 'L', 's': 'D', 'd': 'R'}65while True:66 time.sleep(0.2)67 if keypress.last_key:68 player.change_direction(dir_dict[keypress.last_key])69 keypress.last_key = None70 make_next_frame()71 if player.is_dead:72 break73 print('Score:', player.score)74 print('Highscore:', highscore)7576print('GAME OVER! Reason of death:', player.reason_of_death)77print('You reach:', player.score)78if player.score > highscore:79 config['player']['highscore'] = str(player.score)80 with open('game_data.cfg', 'w') as storefile:81 config.write(storefile)82 print('New highscore! Previous:', highscore)83else: ...

Full Screen

Full Screen

d09ring.py

Source:d09ring.py Github

copy

Full Screen

1class Cell:2 __slots__ = ['value', 'next', 'prev']3 def __init__(self, *, value, next, prev):4 self.value = value5 self.next = next6 self.prev = prev7 def __str__(self):8 return '(%s%d%s)' % (9 ('< ' if self.prev else ': '),10 self.value,11 (' >' if self.next else ' :'),12 )13class Ring:14 def __init__(self, initial_value):15 self.current = cell = Cell(value=initial_value, next=None, prev=None)16 cell.next = cell.prev = cell17 self._len = 118 def seek(self, delta):19 if delta > 0:20 for x in range(delta):21 self.current = self.current.next22 elif delta < 0:23 for x in range(-delta):24 self.current = self.current.prev25 def insert(self, rel_index, value, make_current=False):26 self.seek(rel_index)27 insert_after_cell = self.current28 cell = Cell(value=value, next=insert_after_cell.next, prev=insert_after_cell)29 insert_after_cell.next.prev = cell30 insert_after_cell.next = cell31 if make_current:32 self.current = cell33 self._len += 134 self.verify()35 def pop(self, rel_index):36 assert self._len >= 137 self.seek(rel_index)38 del_cell = self.current39 del_cell.next.prev = del_cell.prev40 del_cell.prev.next = del_cell.next41 self.current = del_cell.next42 del_cell.next = del_cell.prev = None43 self._len -= 144 self.verify()45 return del_cell.value46 def __len__(self):47 return self._len48 def iter(self, back=False):49 cell = self.current50 seen = set()51 while cell not in seen:52 yield cell.value53 seen.add(cell)54 cell = (cell.prev if back else cell.next)55 def __iter__(self):56 return self.iter()57 def riter(self):58 return self.iter(back=True)59 def verify(self):60 pass61if __name__ == '__main__':62 r = Ring('1')63 r.seek(1)64 r.insert(0, '2')65 r.seek(1)66 r.insert(0, '3')67 r.seek(-1)...

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