summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-29 23:00:32 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-29 23:02:08 +0200
commit38dfde05f5be3cdd69e6fee66e7968b776b0ed9f (patch)
tree7b4ba1cec98b002150f372e351aefff58ec7ef4d /factory
parent3b75e132fd1f302b604e76f4c1a0361c32ba50d4 (diff)
downloadfactory-boy-38dfde05f5be3cdd69e6fee66e7968b776b0ed9f.tar
factory-boy-38dfde05f5be3cdd69e6fee66e7968b776b0ed9f.tar.gz
declarations: Rename RelatedFactory.name (See #58).
Use less conflict-prone factory_related_name. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory')
-rw-r--r--factory/declarations.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/factory/declarations.py b/factory/declarations.py
index 974b4ac..17f4434 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -22,6 +22,7 @@
import itertools
+import warnings
from . import compat
from . import utils
@@ -428,9 +429,18 @@ class RelatedFactory(PostGenerationDeclaration):
calling the related factory
"""
- def __init__(self, factory, name='', **defaults):
+ def __init__(self, factory, factory_related_name='', **defaults):
super(RelatedFactory, self).__init__()
- self.name = name
+ if factory_related_name == '' and defaults.get('name') is not None:
+ warnings.warn(
+ "Usage of RelatedFactory(SomeFactory, name='foo') is deprecated"
+ " and will be removed in the future. Please use the"
+ " RelatedFactory(SomeFactory, 'foo') or"
+ " RelatedFactory(SomeFactory, factory_related_name='foo')"
+ " syntax instead", PendingDeprecationWarning, 2)
+ factory_related_name = defaults.pop('name')
+
+ self.name = factory_related_name
self.defaults = defaults
if isinstance(factory, type):