summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Rauenzahn <rich@vmware.com>2016-04-12 14:57:28 -0700
committerRich Rauenzahn <rich@vmware.com>2016-04-12 14:57:28 -0700
commitd9098a809db170f8ffc52efe3e5c6e7f48aa2893 (patch)
treeaac7a9246a74cc3bcfe67dc69c362ad81cbca306
parentfbcf1285b9b756ef7b8d8cf7fcfe8ad245f79bf6 (diff)
downloadfactory-boy-d9098a809db170f8ffc52efe3e5c6e7f48aa2893.tar
factory-boy-d9098a809db170f8ffc52efe3e5c6e7f48aa2893.tar.gz
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