def test_insert_two_elements(): linked_list = LinkedList() linked_list.insert("beton") linked_list.insert(431) assert linked_list.head.get_value() == 431 next_head = linked_list.head.get_next() assert next_head.get_value() == "beton" assert next_head.get_next() is None
def test_delete_one_from_nonempty_list(): linked_list = LinkedList() linked_list.insert(431) linked_list.insert("bacci") linked_list.insert(7.05) assert linked_list.head.get_value() == 7.05 linked_list.delete_last() assert linked_list.head.get_value() == "bacci"
def __init__(self): self.keyboard = kController() self.mouse = mController() self.instructions = LinkedList() self.special_keys = { 'space': Key.space, 'enter': Key.enter, 'lalt': Key.alt_l, 'lshift': Key.shift_l, 'right': Key.right, 'left': Key.left, 'down': Key.down, 'up': Key.up, 'esc': Key.esc, 'delete': Key.delete, 'backspace': Key.backspace, 'tab': Key.tab, 'capslock': Key.caps_lock, 'rshift': Key.shift_r, 'rctrl': Key.ctrl_r, 'ralt': Key.alt_r, 'f1': Key.f1, 'f2': Key.f2, 'f3': Key.f3, 'f4': Key.f4, 'f5': Key.f5, 'f6': Key.f6, 'f7': Key.f7, 'f8': Key.f8, 'f9': Key.f9, 'f10': Key.f10, 'f11': Key.f11, 'f12': Key.f12, 'leftClick': Button.left, 'rightClick': Button.right }
class QueueFromLinkedList: def __init__(self): self.size = 0 self.storage = LinkedList() def __len__(self): return self.size def enqueue(self, value): self.storage.add_to_tail(value) self.size += 1 def dequeue(self): if self.size == 0: return None if self.size > 0: self.size -= 1 return self.storage.remove_head()
def __init__(self): self.size = 0 self.storage = LinkedList()
def __init__(self): self.my_list = LinkedList()
class Stack: def __init__(self): self.my_list = LinkedList() def push(self, data): self.my_list.add_head(data)
def test_delete_all_from_nonempty_list(): linked_list = LinkedList() linked_list.insert(431) linked_list.insert("bacci") linked_list.insert(7.05) assert linked_list.head.get_value() == 7.05 linked_list.delete_last() assert linked_list.head.get_value() == "bacci" linked_list.delete_last() assert linked_list.head.get_value() == 431 linked_list.delete_last() with pytest.raises(AttributeError): linked_list.head.get_value()
def test_insert(): linked_list = LinkedList() linked_list.insert(48) assert linked_list.head.get_value() == 48 assert linked_list.head.get_next() is None
def test_size_three_elements(): linked_list = LinkedList() # Insert three elements for _ in range(3): linked_list.insert(431) assert linked_list.size() == 3
def test_size_one_element(): linked_list = LinkedList() linked_list.insert(431) assert linked_list.size() == 1
class AutoClicker: def __init__(self): self.keyboard = kController() self.mouse = mController() self.instructions = LinkedList() self.special_keys = { 'space': Key.space, 'enter': Key.enter, 'lalt': Key.alt_l, 'lshift': Key.shift_l, 'right': Key.right, 'left': Key.left, 'down': Key.down, 'up': Key.up, 'esc': Key.esc, 'delete': Key.delete, 'backspace': Key.backspace, 'tab': Key.tab, 'capslock': Key.caps_lock, 'rshift': Key.shift_r, 'rctrl': Key.ctrl_r, 'ralt': Key.alt_r, 'f1': Key.f1, 'f2': Key.f2, 'f3': Key.f3, 'f4': Key.f4, 'f5': Key.f5, 'f6': Key.f6, 'f7': Key.f7, 'f8': Key.f8, 'f9': Key.f9, 'f10': Key.f10, 'f11': Key.f11, 'f12': Key.f12, 'leftClick': Button.left, 'rightClick': Button.right } def add_instruction(self, button): self.instructions.add_node(button) def remove_instruction(self): self.instructions.remove_node() def keyboard_press(self, vals, t, lbl): if lbl: print(f'Type {vals} letter by letter and pause for {t}') for v in vals: # print(f'Typing {v} and pausing for {t}') self.keyboard.press(v) self.keyboard.release(v) time.sleep(t) elif len(vals) > 1: if self.special_keys.get(vals) is None: # print(f'Type {vals} and pause for {t}') self.keyboard.type(vals) else: # print(f'Press {self.special_keys[vals]} and pause for {t}') self.keyboard.press(self.special_keys[vals]) self.keyboard.release(self.special_keys[vals]) time.sleep(t) else: # print(f'Press {vals} and pause for {t}') self.keyboard.press(vals) self.keyboard.release(vals) time.sleep(t) def mouse_click(self, button, t, x=-1, y=-1): if x == -1: print(f'Clicking {self.special_keys[button]} and pausing for {t}') self.mouse.press(self.special_keys[button]) self.mouse.release(self.special_keys[button]) time.sleep(t) else: print(f'Clicking {self.special_keys[button]} at {x},{y} and pausing for {t} ') self.mouse.position = (x, y) self.mouse.press(self.special_keys[button]) self.mouse.release(self.special_keys[button]) time.sleep(t) def instruction_hash(self, node): instruction = node.data print(instruction) values = instruction.split(',') if 'Custom' in values: a, b, c, d = values if c == 'Letter By Letter': c = True else: c = False self.keyboard_press(b, float(d), c) # print(f'Type {b} pause for {int(d)} and {c} \n') elif 'Press' in values: a, b, c = values self.keyboard_press(b, float(c), False) # print(f'Press {b} pause for {int(c)} and {False}') elif 'Mouse' in values: if len(values) == 5: a, b, c, d, e = values self.mouse_click(b, float(e), c[2:], d[2:]) # print(f'Click {b} pause for {int(e)} at {c[2:]} {d[2:]}') else: a, b, c = values self.mouse_click(b, float(c)) # print(f'Click {b} pause for {int(c)}') def execute(self, r): for _ in range(r): curr = self.instructions.head if curr.next is None: return else: curr = curr.next while curr is not None: self.instruction_hash(curr) curr = curr.next