I need to test the Photo model of my Django application. How can I mock the ImageField with a test image file?
tests.py
class PhotoT
Tell the mock library to create a mock object based on Django's File class
import mock from django.core.files import File file_mock = mock.MagicMock(spec=File, name='FileMock')
and then use in your tests
newPhoto.image = file_mock