mercredi 26 septembre 2018

Pytest Tkinter Messagebox

My program generates an Alert / Message Box using the code below.

import tkinter as tk
from tkinter import messagebox

root = tk.Tk()
root.withdraw()
messagebox.showwarning('End of Data', "You have reached the end of the data.")

I want to run a simple unit test on this code. I want to assert that the message box appears and that the text in the message box is "You have reached the end of the data.". Perhaps something like assert appears and assert message == "You have reached the end of the data.".

Ideally I'd like to do this using PyTest, however solutions using other frameworks would still be greatly appreciated.

(For context I am using Python 3.)

Aucun commentaire:

Enregistrer un commentaire