summaryrefslogtreecommitdiff
path: root/factory/base.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-02 23:07:03 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-02 23:07:03 +0200
commit69e7a86875f97dc12e941302fabe417122f2cb7e (patch)
tree096d558041ad5ff0794a159580aab09b8f7bb9a5 /factory/base.py
parent54a915fa25a66d3b7732a096eba7c2dd4a7b5a8e (diff)
downloadfactory-boy-69e7a86875f97dc12e941302fabe417122f2cb7e.tar
factory-boy-69e7a86875f97dc12e941302fabe417122f2cb7e.tar.gz
Add Factory.FACTORY_HIDDEN_ARGS.
Fields listed in this class attributes will be removed from the kwargs dict passed to the associated class for building/creation.
Diffstat (limited to 'factory/base.py')
-rw-r--r--factory/base.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/factory/base.py b/factory/base.py
index ff3e558..58cd50b 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -234,6 +234,9 @@ class BaseFactory(object):
# List of arguments that should be passed as *args instead of **kwargs
FACTORY_ARG_PARAMETERS = ()
+ # List of attributes that should not be passed to the underlying class
+ FACTORY_HIDDEN_ARGS = ()
+
@classmethod
def _setup_next_sequence(cls):
"""Set up an initial sequence value for Sequence attributes.
@@ -305,6 +308,10 @@ class BaseFactory(object):
target_class = getattr(cls, CLASS_ATTRIBUTE_ASSOCIATED_CLASS)
kwargs = cls._adjust_kwargs(**kwargs)
+ # Remove 'hidden' arguments.
+ for arg in cls.FACTORY_HIDDEN_ARGS:
+ del kwargs[arg]
+
# Extract *args from **kwargs
args = tuple(kwargs.pop(key) for key in cls.FACTORY_ARG_PARAMETERS)