summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2016-04-18 23:19:56 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2016-04-18 23:19:56 +0200
commit187d849ea5388738013e1c3fbbab16378b86fa84 (patch)
treeaac7a9246a74cc3bcfe67dc69c362ad81cbca306
parentfbcf1285b9b756ef7b8d8cf7fcfe8ad245f79bf6 (diff)
parentd9098a809db170f8ffc52efe3e5c6e7f48aa2893 (diff)
downloadfactory-boy-187d849ea5388738013e1c3fbbab16378b86fa84.tar
factory-boy-187d849ea5388738013e1c3fbbab16378b86fa84.tar.gz
Merge pull request #292 from rrauenza/master
Add custom error message when django_get_or_create is missing an input.
-rw-r--r--factory/django.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/factory/django.py b/factory/django.py
index b3c508c..43434c2 100644
--- a/factory/django.py
+++ b/factory/django.py
@@ -29,6 +29,8 @@ import types
import logging
import functools
+from . import errors
+
"""factory_boy extensions for use with the Django framework."""
try:
@@ -157,6 +159,11 @@ class DjangoModelFactory(base.Factory):
key_fields = {}
for field in cls._meta.django_get_or_create:
+ if field not in kwargs:
+ raise errors.FactoryError(
+ "django_get_or_create - "
+ "Unable to find initialization value for '%s' in factory %s" %
+ (field, cls.__name__))
key_fields[field] = kwargs.pop(field)
key_fields['defaults'] = kwargs