import unittest
import tkinter as tk
import sqlite3
from tkinter import ttk
from library import show_books, tree, cursor
class TestLibrary(unittest.TestCase):
def test_show_books(self):
cursor.execute("DELETE FROM books")
cursor.execute(
"INSERT INTO books (title, author, year) VALUES (?, ?, ?)",
("Гарри Поттер", "Роулинг", 1997)
)
show_books()
books = tree.get_children()
self.assertEqual(len(books), 1)
if __name__ == "__main__":
unittest.main()