Codebase list factory-boy / d9098a8
Add custom error message when django_get_or_create is missing an input. Rich Rauenzahn 8 years ago
1 changed file(s) with 7 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2828 import logging
2929 import functools
3030
31 from . import errors
32
3133 """factory_boy extensions for use with the Django framework."""
3234
3335 try:
156158
157159 key_fields = {}
158160 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__))
159166 key_fields[field] = kwargs.pop(field)
160167 key_fields['defaults'] = kwargs
161168