Tell the mock library to create a mock object based on Django's File class
from django.core.files import File
file_mock = mock.MagicMock(spec=File, name='FileMock')
and then use in your tests
newPhoto.image = file_mock
Thanks, but I do not like to use 3rd party modules for this purpose...
newPhoto.image = open(/path/to/foo.jpg)