How to use make_step method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

numbers_solvers.py

Source:numbers_solvers.py Github

copy

Full Screen

...13 num_in_b1 = int_to_base(n, b1)14 num_in_b2 = int_to_base(n, b2)15 self._print_number_in_base(n, b1, attention=True, mark_pos='num',16 orientation=1)17 self.make_step()18 self.go_to_mark('start')19 self.move_down()20 self.print_number(b1, orientation=1, attention=1)21 self.print_symbol(S.base_conversion, orientation=1,22 attention=1, mark_pos='base_conversion_sign')23 self.print_number(b2, orientation=1, attention=1)24 self.make_step()25 self.go_to_mark_range('num')26 self.move_down(2)27 num_in_b1_rev = num_in_b1.copy()28 num_in_b1_rev.reverse()29 for i, digit in enumerate(num_in_b1_rev):30 self.mark_current_pos('s')31 # TODO why 3?32 self.move_left(3)33 self.print_symbol(S.add)34 self.print_number(digit, orientation=1)35 self.print_symbol(S.product, orientation=1)36 self._print_number_in_base(37 b1**i, base=b2, orientation=1)38 self.print_symbol(S.eq, orientation=1)39 self.print_number(b1**i*digit, orientation=1)40 self.make_step()41 self.go_to_mark('s')42 self.move_down()43 self._print_number_in_base(n, b2, attention=True, reset=True)44 self.paper.make_step()45 self.go_to_mark('base_conversion_sign')46 self.move_down()47 self.print_symbol(S.yes)48 self.set_attention_current_pos()49 self.paper.make_step()50 self.set_attention_current_pos(reset=True)51 self.make_step()52 return53class IsDivisibleBySolver(Solver):54 def play(self, problem):55 a, b = problem['a'], problem['b']56 self.paper.print_number(a)57 self.go_to_mark('start')58 self.move_down()59 self.paper.print_number(b)60 self.paper.print_symbol(S.is_divisible_by)61 self.move_down()62 self.paper.make_step()63 if a % b == 0:64 self.paper.print_symbol(S.yes, attention=True, reset=True)65 else:66 self.paper.print_symbol(S.no, attention=True, reset=True)67 self.paper.make_step()68class DivRemainderSolver(Solver):69 def play(self, problem):70 a = problem['a']71 b = problem['b']72 self.paper._set_position(0, 0)73 self.paper.print_number(a, orientation=1, reset=True)74 self.paper.move_left()75 self.paper.mark_current_pos('margin')76 77 self.paper.move_right()78 self.paper.print_symbol(S.remainder)79 self.paper.print_number(b, orientation=1)80 81 self.paper.make_step()82 for i in range(int((a - a % b) / b)):83 self.paper.go_to_mark('margin')84 self.paper.move_down()85 self.paper.mark_current_pos('margin')86 87 self.paper.print_number(b, orientation=-1)88 self.paper.print_symbol(12, orientation=-1)89 self.paper.go_to_mark('margin')90 self.paper.move_down()91 self.paper.mark_current_pos('margin')92 93 self.paper.make_step(solver='SubtractSolver')94 self.paper.print_number(a - b * (i + 1))95class IsPrimeSolverEasy(Solver):96 def play(self, problem):97 n = problem['a']98 is_prime_ = is_prime(n)99 self.paper.print_number(n, orientation=-1)100 self.mark_current_pos('prime_sign')101 self.paper.print_symbol(S.is_prime, attention=True,102 preserve_pos=True)103 self.move_down()104 self.make_step()105 if is_prime_:106 self.paper.print_symbol(S.yes, attention=True, reset=True)107 else:108 self.paper.print_symbol(S.no, attention=True, reset=True)109 self.paper.make_step()110class IsPrimeSolverHard(Solver):111 def play(self, problem):112 n = problem['a']113 is_prime_ = is_prime(n)114 self.print_number(n, mark_pos=('number'))115 self.mark_current_pos('prime_sign')116 self.paper.print_symbol(S.is_prime, attention=True,117 preserve_pos=True)118 self.paper.make_step()119 # ha elég kicsi a szám, akkor tudhatjuk fejből120 if n <= 23:121 self.move_down()122 sign = S.yes if is_prime_ else S.no123 self.paper.print_symbol(sign, attention=True, reset=True)124 self.paper.make_step()125 return126 self.go_to_mark_range('number', end=True)127 # ha ennél nagyobb, akkor ellenőrizzük, hogy vannak-e osztói128 self.move_right(1)129 self.print_symbol(S.sqrt, attention=True, reset=True,130 orientation=1)131 self.paper.make_step()132 # +2: mert csak becsüljük a gyököt, inkább legyen biztos.133 # kell?134 sqrt_n = int(np.sqrt(n)) + 2135 self.print_number(sqrt_n, orientation=1, mark_pos='sqrt',136 preserve_pos=True)137 self.paper.make_step()138 possible_divisors = primes_lt(sqrt_n)139 self.move_down()140 self.move_left()141 for divisor in possible_divisors:142 self.mark_current_pos('div_sign')143 self.print_symbol(S.is_divisible_by,144 attention=True, reset=True)145 self.set_attention_mark_range('number')146 self.print_number(divisor, orientation=1,147 attention=True, reset=True)148 self.make_step()149 if n % divisor == 0:150 self.print_symbol(S.yes, attention=True)151 self.go_to_mark('prime_sign')152 self.move_down()153 self.make_step()154 # találtunk osztót, tehát nem prím155 self.print_symbol(S.no, attention=True, reset=True)156 self.make_step()157 return158 else:159 self.print_symbol(S.no, attention=True)160 # self.set_attention(sqrt_pos)161 self.make_step()162 self.go_to_mark('div_sign')163 self.move_down()164 self.go_to_mark('prime_sign')165 self.move_down()166 self.print_symbol(S.yes, attention=True, reset=True)167 self.paper.make_step()168class FactorizeSolver(Solver):169 def play(self, problem):170 primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]171 a = problem['a']172 self.paper.print_number(a)173 self.paper.print_symbol(S.factorize)174 self.go_to_mark('start')175 self.move_down()176 i = 0177 j = 0178 factor = primes[i]179 self.make_step()180 while a != 1:181 while (a % factor == 0) and (a != 1):182 self.go_to_mark('start')183 self.move_down(j+1)184 self.move_right()185 self.paper.print_number(a, orientation=-1, attention=True)186 self.paper.print_symbols(187 [S.div],188 orientation=-1, attention=True, reset=True)189 self.paper.print_number(factor, orientation=-1, attention=True)190 self.paper.make_step()191 a = a // factor192 j += 1193 i += 1194 factor = primes[i]195 self.paper.make_step()196 self.paper.make_step()197class PlaceValueSolver(Solver):198 def play(self, problem):199 number = problem['number']200 place = problem['place']201 self.paper.print_number(number, orientation=1, reset=True)202 self.print_symbol(S.last_digit)203 self.paper.print_number(place, orientation=1)204 for i in range(1, place + 1):205 self.paper.make_step()206 self.paper._set_position(i, 0)207 for _ in range(i):208 self.paper.print_symbol(0)209 self.paper.print_number(int(str(number)[i:]), orientation=1)210 self.paper.print_symbol(S.last_digit)211 self.paper.print_number(i, orientation=1)212class RoundNumber(Solver):213 pass214def factorize(num):215 factors = []216 while num != 1:217 for i in range(2, num + 1):218 if num % i == 0:219 factors.append(i)220 num = num // i221 break222 return factors223class DoubleFactorBaseClass(Solver):224 def _print_factors(self, mark, number):225 self.go_to_mark_range(mark, end=True)226 self.move_down()227 self.paper.print_symbol(S.factorize, orientation=0)228 self.paper.move_down()229 factors_a = factorize(number)230 for factor in factors_a:231 self.paper.print_number(factor, orientation=-1, preserve_pos=True)232 self.paper.move_down()233 self.make_step(solver='FactorizeSolver')234 def draw_factors_ab(self, a, b, symbol='gcd'):235 self.paper.move_down(2)236 self.paper.print_symbol(getattr(S, symbol), orientation=-1, mark_pos=symbol)237 self.paper.mark_current_pos('a_current', vertical_offset=2)238 self.paper.print_number(a, orientation=-1, mark_pos='a')239 self.paper.go_to_mark(symbol)240 self.move_right()241 self.paper.print_number(b, orientation=1, mark_pos='b')242 self.paper.mark_current_pos('b_current', vertical_offset=2,243 horizontal_offset=-1)244 self.make_step()245 self._print_factors('a', a)246 self._print_factors('b', b)247 def _move_mark_down(self, mark):248 self.paper.go_to_mark(mark)249 self.paper.delete_word_at_point()250 self.paper.move_down()251 self.paper.mark_current_pos(mark)252 def add_factor_to_c(self, factor):253 self.paper.go_to_mark('c_current')254 if self.first_factor_c:255 self.c_factors = [factor]256 else:257 self.paper.print_symbol(S.product, orientation=1)258 self.c_factors.append(factor)259 self.paper.print_number(factor, orientation=1)260 self.paper.mark_current_pos('c_current')261 self.first_factor_c = False262 def print_solution(self):263 c = np.product(self.c_factors)264 self.paper.go_to_mark('c_current')265 self.paper.print_symbol(S.eq)266 self.paper.print_number(c, orientation=1)267 self.paper.go_to_mark('answer')268 self.print_number(c, orientation=1)269 self.paper.print_symbol(S.end)270class GCDSolver(DoubleFactorBaseClass):271 def play(self, problem):272 a,b = problem['a'], problem['b']273 self.draw_factors_ab(a, b)274 self.paper.go_to_mark('start')275 self.print_symbol(S.gcd)276 self.print_symbol(S.eq)277 self.paper.mark_current_pos('c_current')278 self.paper.go_to_mark('a_current')279 current_factor_a = self.paper.get_number_at_position()280 self.paper.go_to_mark('b_current')281 current_factor_b = self.paper.get_number_at_position()282 self.first_factor_c = True283 self.make_step()284 while current_factor_a != 0:285 while current_factor_a != current_factor_b:286 if 0 in (current_factor_a, current_factor_b):287 current_factor_a = 1288 break289 if current_factor_a < current_factor_b:290 self._move_mark_down('a_current')291 current_factor_a = self.paper.get_number_at_position()292 if current_factor_a > current_factor_b:293 self._move_mark_down('b_current')294 current_factor_b = self.paper.get_number_at_position()295 self.make_step()296 self.add_factor_to_c(current_factor_a)297 self._move_mark_down('a_current')298 current_factor_a = self.paper.get_number_at_position()299 self._move_mark_down('b_current')300 current_factor_b = self.paper.get_number_at_position()301 self.make_step()302 self.print_solution()303 self.paper.set_attention_current_pos()304 self.paper.make_step()305class LCMSolver(DoubleFactorBaseClass):306 307 def play(self, problem):308 a,b = problem['a'], problem['b']309 self.draw_factors_ab(a, b, 'lcm')310 self.paper.go_to_mark('start')311 self.print_symbol(S.lcm)312 self.print_symbol(S.eq)313 self.paper.mark_current_pos('c_current')314 self.make_step()315 self.paper.go_to_mark('a_current')316 current_factor_a = self.paper.get_number_at_position()317 self.paper.go_to_mark('b_current')318 current_factor_b = self.paper.get_number_at_position()319 self.first_factor_c = True320 while current_factor_a + current_factor_b != 0:321 if (current_factor_a < current_factor_b322 and current_factor_a != 0) or current_factor_b == 0:323 self.add_factor_to_c(current_factor_a)324 self._move_mark_down('a_current')325 current_factor = current_factor_a =\326 self.paper.get_number_at_position()327 elif (current_factor_b < current_factor_a328 and current_factor_b != 0) or current_factor_a == 0:329 self.add_factor_to_c(current_factor_b)330 self._move_mark_down('b_current')331 current_factor_b = self.paper.get_number_at_position()332 elif current_factor_a == current_factor_b and current_factor_a != 0:333 current_factor = current_factor_a334 self.add_factor_to_c(current_factor_a)335 self._move_mark_down('a_current')336 current_factor_a = self.paper.get_number_at_position()337 self._move_mark_down('b_current')338 current_factor_b = self.paper.get_number_at_position()339 else:340 raise RuntimeError341 self.make_step()342 self.print_solution()343 self.paper.set_attention_current_pos()...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...86 self._knee_joint._pub.publish(numpy.radians(self.current_pos[2]))87 88 rospy.sleep(speed)89 #print(self.current_pos)90 def make_step(self, trajectory, speed):91 """ simulates one full movement of a step """92 for item in trajectory:93 self.move_to_point(item, speed)94 rospy.sleep(0.001)95class Joint():96 """ Simulating servomotor """97 def __init__(self, command, up_limit, low_limit):98 self.command = command99 self._pub = rospy.Publisher(self.command, Float64, queue_size=10)100 self.upper_limit = up_limit101 self.lower_limit = low_limit102 def set_joint_value(self, value):103 """ Publishes recieved value to simulated joint """104 self.value = self.deg2rad(value)105 if self.value >= self.upper_limit:106 self.value = self.upper_limit107 elif self.value <= self.lower_limit:108 self.value = self.lower_limit109 110 self._pub.publish(self.value)111 rospy.loginfo(self.value)112class Robot():113 def __init__(self):114 115 rospy.init_node('robot_control')116 rospy.loginfo("Initializing the robot")117 service=rospy.Service('command_service',Service_GUI_Command, self.get_command)118 self.command = -1119 self._steering_value_sub = rospy.Subscriber('steering_value', Int8, self.update_steering_value)120 self.steering = -1121 self.mode = 0122 # leg objects123 self._leg1 = Leg(name="FL", servo1=joint_node["shoulder1"], servo2=joint_node["limb1"], servo3=joint_node["knee1"])124 self._leg2 = Leg(name="FR", servo1=joint_node["shoulder2"], servo2=joint_node["limb2"], servo3=joint_node["knee2"])125 self._leg3 = Leg(name="BL", servo1=joint_node["shoulder3"], servo2=joint_node["limb3"], servo3=joint_node["knee3"])126 self._leg4 = Leg(name="BR", servo1=joint_node["shoulder4"], servo2=joint_node["limb4"], servo3=joint_node["knee4"])127 def update_steering_value(self, value):128 self.steering = value.data129 def initialize(self):130 """ setting robot legs to base position"""131 self._leg1.set_idle_position()132 self._leg2.set_idle_position()133 self._leg3.set_idle_position()134 self._leg4.set_idle_position()135 def work_threads(self, t1, t2, t3, t4):136 t1.start()137 t2.start()138 t3.start()139 t4.start()140 t1.join()141 t2.join()142 t3.join()143 t4.join()144 def set_idle(self):145 self.speed = 0.01146 t1 = Thread(target=self._leg1.move_to_point, args=(self._leg1.base_position, self.speed,))147 t2 = Thread(target=self._leg2.move_to_point, args=(self._leg2.base_position, self.speed,))148 t3 = Thread(target=self._leg3.move_to_point, args=(self._leg3.base_position, self.speed,))149 t4 = Thread(target=self._leg4.move_to_point, args=(self._leg4.base_position, self.speed,))150 151 self.work_threads(t1, t2, t3, t4)152 def gait_init(self):153 self.speed = 0.01154 self._leg1.move_to_point(gait_p4[2], self.speed)155 self._leg4.move_to_point(gait_p3[2], self.speed)156 self._leg2.move_to_point(gait_p2[2], self.speed)157 self._leg3.move_to_point(gait_p1[2], self.speed)158 def gait(self):159 self.speed1 = 0.01160 self.speed2 = 0.01161 t1 = Thread(target=self._leg1.make_step, args=(gait_p1, self.speed1,))162 t2 = Thread(target=self._leg2.make_step, args=(gait_p3, self.speed2,))163 t3 = Thread(target=self._leg3.make_step, args=(gait_p2, self.speed2,))164 t4 = Thread(target=self._leg4.make_step, args=(gait_p4, self.speed2,))165 self.work_threads(t1, t2, t3, t4)166 t1 = Thread(target=self._leg1.make_step, args=(gait_p2, self.speed2,))167 t2 = Thread(target=self._leg2.make_step, args=(gait_p4, self.speed2,))168 t3 = Thread(target=self._leg3.make_step, args=(gait_p3, self.speed2,))169 t4 = Thread(target=self._leg4.make_step, args=(gait_p1, self.speed1,))170 self.work_threads(t1, t2, t3, t4)171 t1 = Thread(target=self._leg1.make_step, args=(gait_p3, self.speed2,))172 t2 = Thread(target=self._leg2.make_step, args=(gait_p1, self.speed1,))173 t3 = Thread(target=self._leg3.make_step, args=(gait_p4, self.speed2,))174 t4 = Thread(target=self._leg4.make_step, args=(gait_p2, self.speed2,))175 self.work_threads(t1, t2, t3, t4)176 t1 = Thread(target=self._leg1.make_step, args=(gait_p4, self.speed2))177 t2 = Thread(target=self._leg2.make_step, args=(gait_p2, self.speed2))178 t3 = Thread(target=self._leg3.make_step, args=(gait_p1, self.speed1))179 t4 = Thread(target=self._leg4.make_step, args=(gait_p3, self.speed2))180 self.work_threads(t1, t2, t3, t4)181 def trot(self):182 self.speed = 0.01183 t1 = Thread(target=self._leg1.make_step, args=(step1, self.speed,))184 t2 = Thread(target=self._leg2.make_step, args=(step2, self.speed,))185 t3 = Thread(target=self._leg3.make_step, args=(step2, self.speed,))186 t4 = Thread(target=self._leg4.make_step, args=(step1, self.speed,))187 188 self.work_threads(t1, t2, t3, t4)189 def go_left(self):190 self.speed = 0.01191 self._leg1.make_step(left1, self.speed)192 self._leg3.make_step(left1, self.speed)193 194 t1 = Thread(target=self._leg1.move_to_point, args=(self._leg1.base_position, self.speed,))195 t2 = Thread(target=self._leg2.move_to_point, args=(right1[1], self.speed,))196 t3 = Thread(target=self._leg3.move_to_point, args=(self._leg3.base_position, self.speed,))197 t4 = Thread(target=self._leg4.move_to_point, args=(right1[1], self.speed,))198 self.work_threads(t1, t2, t3, t4)199 self._leg2.make_step(side_to_base, self.speed)200 self._leg4.make_step(side_to_base, self.speed)201 def go_right(self):202 self.speed = 0.01203 self._leg2.make_step(right1, self.speed)204 self._leg4.make_step(right1, self.speed)205 t1 = Thread(target=self._leg1.move_to_point, args=(left1[1], self.speed,))206 t2 = Thread(target=self._leg2.move_to_point, args=(self._leg2.base_position, self.speed,))207 t3 = Thread(target=self._leg3.move_to_point, args=(left1[1], self.speed,))208 t4 = Thread(target=self._leg4.move_to_point, args=(self._leg4.base_position, self.speed,))209 self.work_threads(t1, t2, t3, t4)210 self._leg1.make_step(side_to_base, self.speed)211 self._leg3.make_step(side_to_base, self.speed)212 def spin_left(self):213 self.speed = 0.01214 self._leg1.make_step(left1, self.speed)215 self._leg4.make_step(right1, self.speed)216 t1 = Thread(target=self._leg1.move_to_point, args=(self._leg1.base_position, self.speed,))217 t2 = Thread(target=self._leg2.move_to_point, args=(right1[1], self.speed,))218 t3 = Thread(target=self._leg3.move_to_point, args=(left1[1], self.speed,))219 t4 = Thread(target=self._leg4.move_to_point, args=(self._leg4.base_position, self.speed,))220 self.work_threads(t1, t2, t3, t4)221 self._leg2.make_step(side_to_base, self.speed)222 self._leg3.make_step(side_to_base, self.speed)223 def spin_right(self):224 self.speed = 0.01225 self._leg2.make_step(right1, self.speed)226 self._leg3.make_step(left1, self.speed)227 t1 = Thread(target=self._leg1.move_to_point, args=(left1[1], self.speed,))228 t2 = Thread(target=self._leg2.move_to_point, args=(self._leg2.base_position, self.speed,))229 t3 = Thread(target=self._leg3.move_to_point, args=(self._leg3.base_position, self.speed,))230 t4 = Thread(target=self._leg4.move_to_point, args=(right1[1], self.speed,))231 self.work_threads(t1, t2, t3, t4)232 self._leg1.make_step(side_to_base, self.speed)233 self._leg4.make_step(side_to_base, self.speed)234 def go_backwards(self):235 self.speed = 0.01236 t1 = Thread(target=self._leg1.make_step, args=(step1_b, self.speed,))237 t2 = Thread(target=self._leg2.make_step, args=(step2_b, self.speed,))238 t3 = Thread(target=self._leg3.make_step, args=(step2_b, self.speed,))239 t4 = Thread(target=self._leg4.make_step, args=(step1_b, self.speed,))240 241 self.work_threads(t1, t2, t3, t4)242 243 def get_command(self, request):244 if request.command=="FORWARD":245 self.command = 1246 return Service_GUI_CommandResponse("Robot going forward")247 elif request.command=="LEFT":...

Full Screen

Full Screen

test_client.py

Source:test_client.py Github

copy

Full Screen

...26 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO happy Pascal 1x1".encode("utf-8"))27 game = init_game(sock, "boring Hawking")28 sock = get_socket_with_mocked_recv(mock_socket_cls, "OMG A 1".encode("utf-8"))29 with pytest.raises(WrongCommand):30 make_step(sock, game)31def test_game_correctly_ends(mocker: MockFixture):32 mock_socket_cls = mocker.patch("socket.socket")33 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO happy Pascal 1x1".encode("utf-8"))34 game = init_game(sock, "boring Hawking")35 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE A 1 STOP X".encode("utf-8"))36 game_over = make_step(sock, game)37 sock.close()38 assert game_over39 assert game.check_winner() == "X"40def test_enemy_wins(mocker: MockFixture):41 mock_socket_cls = mocker.patch("socket.socket")42 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO happy Pascal 3x3".encode("utf-8"))43 game = init_game(sock, "boring Hawking")44 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE A 1".encode("utf-8"))45 set_stdin_value(mocker, "A 2")46 make_step(sock, game)47 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE B 2".encode("utf-8"))48 set_stdin_value(mocker, "B 1")49 make_step(sock, game)50 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE C 3 STOP X".encode("utf-8"))51 game_over = make_step(sock, game)52 assert game_over53 assert game.check_winner() == "X"54def test_gamer_wins(mocker: MockFixture):55 mock_socket_cls = mocker.patch("socket.socket")56 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO happy Pascal 3x3".encode("utf-8"))57 game = init_game(sock, "boring Hawking")58 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE A 2".encode("utf-8"))59 set_stdin_value(mocker, "A 1")60 make_step(sock, game)61 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE B 1".encode("utf-8"))62 set_stdin_value(mocker, "B 2")63 make_step(sock, game)64 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE C 2".encode("utf-8"))65 set_stdin_value(mocker, "C 3")66 make_step(sock, game)67 sock = get_socket_with_mocked_recv(mock_socket_cls, "STOP O".encode("utf-8"))68 game_over = make_step(sock, game)69 assert game_over...

Full Screen

Full Screen

test_server.py

Source:test_server.py Github

copy

Full Screen

...24 game = init_game(sock, 3, "happy Pascal")25 set_stdin_value(mocker, "A 2")26 sock = get_socket_with_mocked_recv(mock_socket_cls, "WRONG_MOVE A 1".encode("utf-8"))27 with pytest.raises(WrongCommand):28 make_step(sock, game)29def test_game_correctly_ends(mocker: MockFixture):30 mock_socket_cls = mocker.patch("socket.socket")31 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO boring Hawking".encode("utf-8"))32 game = init_game(sock, 1, "happy Pascal")33 sendall_spy = mocker.spy(sock, "sendall")34 set_stdin_value(mocker, "A 1")35 make_step(sock, game)36 sock.close()37 assert game.check_winner() == "X"38 sendall_spy.assert_called_once_with("MOVE A 1 STOP X".encode("utf-8"))39def test_game_continues_after_step(mocker: MockFixture):40 mock_socket_cls = mocker.patch("socket.socket")41 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO boring Hawking".encode("utf-8"))42 game = init_game(sock, 2, "happy Pascal")43 sock.close()44 set_stdin_value(mocker, "A 1")45 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE B 1".encode("utf-8"))46 game_over = make_step(sock, game)47 sock.close()48 assert not game_over49 set_stdin_value(mocker, "A 2")50 sock = mock_socket_cls()51 sendall_spy = mocker.spy(sock, "sendall")52 game_over = make_step(sock, game)53 sock.close()54 assert game_over55 sendall_spy.assert_called_once_with("MOVE A 2 STOP X".encode("utf-8"))56def test_enemy_wins(mocker: MockFixture):57 mock_socket_cls = mocker.patch("socket.socket")58 sock = get_socket_with_mocked_recv(mock_socket_cls, "HELO boring Hawking".encode("utf-8"))59 game = init_game(sock, 3, "happy Pascal")60 set_stdin_value(mocker, "A 2")61 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE A 1".encode("utf-8"))62 make_step(sock, game)63 set_stdin_value(mocker, "B 1")64 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE B 2".encode("utf-8"))65 make_step(sock, game)66 set_stdin_value(mocker, "C 2")67 sock = get_socket_with_mocked_recv(mock_socket_cls, "MOVE C 3".encode("utf-8"))68 sendall_spy = mocker.spy(sock, "sendall")69 make_step(sock, game)...

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