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
You can use a temporary file, using tempfile. So you don't need a real file to do your tests.
import tempfile image = tempfile.NamedTemporaryFile(suffix=".jpg").name
If you prefer to do manual clean-up, use tempfile.mkstemp() instead.
tempfile.mkstemp()