summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-15 16:16:20 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-15 16:17:15 +0200
commitc490870c67116387f116528fc8563b8dcba37b3e (patch)
treec0fa3a74dcdf9c8f89141b717de9ea50d1de295c
parentb72fa40e52f3b767144b11f1d83c36d417f023d8 (diff)
downloadfactory-boy-c490870c67116387f116528fc8563b8dcba37b3e.tar
factory-boy-c490870c67116387f116528fc8563b8dcba37b3e.tar.gz
Pass attribute name to PostGenerationDeclaration
-rw-r--r--factory/declarations.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/factory/declarations.py b/factory/declarations.py
index e7c8ed5..037a679 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -419,10 +419,11 @@ class List(SubFactory):
class ExtractionContext(object):
"""Private class holding all required context from extraction to postgen."""
- def __init__(self, value=None, did_extract=False, extra=None):
+ def __init__(self, value=None, did_extract=False, extra=None, for_field=''):
self.value = value
self.did_extract = did_extract
self.extra = extra or {}
+ self.for_field = for_field
def __repr__(self):
return 'ExtractionContext(%r, %r, %r)' % (
@@ -456,7 +457,7 @@ class PostGenerationDeclaration(object):
did_extract = False
kwargs = utils.extract_dict(name, attrs)
- return ExtractionContext(extracted, did_extract, kwargs)
+ return ExtractionContext(extracted, did_extract, kwargs, name)
def call(self, obj, create, extraction_context): # pragma: no cover
"""Call this hook; no return value is expected.