Pourquoi ne Tkinter image s'affichent pas si créé dans une fonction?

Ce code fonctionne:

import tkinter

root = tkinter.Tk()
canvas = tkinter.Canvas(root)
canvas.grid(row = 0, column = 0)
photo = tkinter.PhotoImage(file = './test.gif')
canvas.create_image(0, 0, image=photo)
root.mainloop()

Il me montre l'image.

Maintenant, ce code compile mais il n'affiche pas l'image, et je ne sais pas pourquoi, parce que c'est le même code, dans une classe:

import tkinter

class Test:
    def __init__(self, master):
        canvas = tkinter.Canvas(master)
        canvas.grid(row = 0, column = 0)
        photo = tkinter.PhotoImage(file = './test.gif')
        canvas.create_image(0, 0, image=photo)

root = tkinter.Tk()
test = Test(root)
root.mainloop()