From 5ec4a50edc67073e54218549d6985f934f94b88f Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Wed, 14 Nov 2012 23:42:46 +0100 Subject: Add an extension point for kwargs mangling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- factory/base.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'factory') diff --git a/factory/base.py b/factory/base.py index 20a3a6b..59f37eb 100644 --- a/factory/base.py +++ b/factory/base.py @@ -569,6 +569,11 @@ class Factory(BaseFactory): if building_function and building_function[0]: return building_function[0] + @classmethod + def _adjust_kwargs(cls, **kwargs): + """Extension point for custom kwargs adjustment.""" + return kwargs + @classmethod def _prepare(cls, create, **kwargs): """Prepare an object for this factory. @@ -578,6 +583,7 @@ class Factory(BaseFactory): **kwargs: arguments to pass to the creation function """ target_class = getattr(cls, CLASS_ATTRIBUTE_ASSOCIATED_CLASS) + kwargs = cls._adjust_kwargs(**kwargs) # Extract *args from **kwargs args = tuple(kwargs.pop(key) for key in cls.FACTORY_ARG_PARAMETERS) -- cgit v1.2.3