Add custom error message when django_get_or_create is missing an input.
Rich Rauenzahn
8 years ago
28 | 28 | import logging |
29 | 29 | import functools |
30 | 30 | |
31 | from . import errors | |
32 | ||
31 | 33 | """factory_boy extensions for use with the Django framework.""" |
32 | 34 | |
33 | 35 | try: |
156 | 158 | |
157 | 159 | key_fields = {} |
158 | 160 | for field in cls._meta.django_get_or_create: |
161 | if field not in kwargs: | |
162 | raise errors.FactoryError( | |
163 | "django_get_or_create - " | |
164 | "Unable to find initialization value for '%s' in factory %s" % | |
165 | (field, cls.__name__)) | |
159 | 166 | key_fields[field] = kwargs.pop(field) |
160 | 167 | key_fields['defaults'] = kwargs |
161 | 168 |