I am using pytest to test a to do list program that uses tkinter but when I run my test code the pytest code in the terminal doesn't run. I am not sure if my test code is bad or if I am not calling something correctly but I would love any and all help.
code:
from tkinter import Entry, Listbox
import pytest
from to_do_list import add_item, delete_item
def test_add_item():
assert add_item('test') == 'test'
def test_delete_item():
test_delete = delete_item()
assert not test_delete == 'test'
Code I am trying to test:
def add_item(entry: Entry, listbox:Listbox):
new_item = entry.get()
listbox.insert(END, new_item)
with open('items.txt', 'a') as item_file:
item_file.write(f'\n{new_item}')
def delete_item(listbox: Listbox):
listbox.delete(ACTIVE)
with open('items.txt', 'r+') as item_file:
lines = item_file.readlines()
for line in lines:
if listbox.get(ACTIVE) == line[:-2]:
lines.remove(line)
item_file.write(line)
item_file.close()
In my main code, I have it open a window using this code at the bottom of the code.
window.update()
window.mainloop()