Django factory boy, поля изображений не создаются?
Я попытался следовать стандартному рецепту для полей изображений для django factory boy:
class ConfigurationSingletonFactory(DjangoModelFactory):
class Meta:
model = Configuration
django_get_or_create = ("id",)
id = 1
custom_theme = ImageField(color="blue", width=200, height=200)
class GeneralConfiguration(SingletonModel):
custom_theme = PrivateMediaImageField("Custom background", upload_to="themes", blank=True)
Однако всякий раз, когда я пытаюсь протестировать его:
def test_config(self):
conf = GeneralConfigurationSingletonFactory(
custom_theme__name="image.png"
)
print(conf.custom_theme.width)
self.assertEqual(conf.custom_theme.width, 200)
Выскакивает следующая ошибка:
ValueError: The 'custom_theme' attribute has no file associated with it.
Что я не так понимаю, я думал, что сделал именно то, о чем говорит https://factoryboy.readthedocs.io/en/stable/orms.html#factory.django.ImageField?