Pytest plugin opening GUI
Tkinter.Tk().mainloop() is a while True loop. You won't be getting out of it. There are two ways to solve your problem in my opinion:
Use pytest inside Tkinter app. You can invoke pytest within the tkinter code like this.
Use pytest in different thread and pipe the output of pytest to Tkinter app.