summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--factory/__init__.py4
-rw-r--r--factory/declarations.py12
-rw-r--r--tests/test_using.py4
3 files changed, 10 insertions, 10 deletions
diff --git a/factory/__init__.py b/factory/__init__.py
index 7f40d6f..cc5b788 100644
--- a/factory/__init__.py
+++ b/factory/__init__.py
@@ -47,12 +47,12 @@ from declarations import (
Sequence,
LazyAttributeSequence,
SelfAttribute,
- LazyContainerAttribute,
+ ContainerAttribute,
SubFactory,
lazy_attribute,
sequence,
lazy_attribute_sequence,
- lazy_container_attribute,
+ container_attribute,
)
diff --git a/factory/declarations.py b/factory/declarations.py
index c28e6af..0ce7071 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -108,7 +108,7 @@ class LazyAttributeSequence(Sequence):
return self.function(obj, self.type(sequence))
-class LazyContainerAttribute(OrderedDeclaration):
+class ContainerAttribute(OrderedDeclaration):
"""Variant of LazyAttribute, also receives the containers of the object.
Attributes:
@@ -118,12 +118,12 @@ class LazyContainerAttribute(OrderedDeclaration):
not passed in (i.e used outside a SubFactory).
"""
def __init__(self, function, strict=True, *args, **kwargs):
- super(LazyContainerAttribute, self).__init__(*args, **kwargs)
+ super(ContainerAttribute, self).__init__(*args, **kwargs)
self.function = function
self.strict = strict
def evaluate(self, sequence, obj, containers=()):
- """Evaluate the current LazyContainerAttribute.
+ """Evaluate the current ContainerAttribute.
Args:
obj (LazyStub): a lazy stub of the object being constructed, if
@@ -133,7 +133,7 @@ class LazyContainerAttribute(OrderedDeclaration):
"""
if self.strict and not containers:
raise TypeError(
- "A LazyContainerAttribute in 'strict' mode can only be used "
+ "A ContainerAttribute in 'strict' mode can only be used "
"within a SubFactory.")
return self.function(obj, containers)
@@ -186,5 +186,5 @@ def sequence(func):
def lazy_attribute_sequence(func):
return LazyAttributeSequence(func)
-def lazy_container_attribute(func):
- return LazyContainerAttribute(func, strict=False)
+def container_attribute(func):
+ return ContainerAttribute(func, strict=False)
diff --git a/tests/test_using.py b/tests/test_using.py
index d1e4262..a93c968 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -472,9 +472,9 @@ class SubFactoryTestCase(unittest.TestCase):
foo = 30
side_a = factory.SubFactory(SideAFactory,
- inner_from_a__a=factory.LazyContainerAttribute(lambda obj, containers: containers[1].foo * 2))
+ inner_from_a__a=factory.ContainerAttribute(lambda obj, containers: containers[1].foo * 2))
side_b = factory.SubFactory(SideBFactory,
- inner_from_b=factory.LazyContainerAttribute(lambda obj, containers: containers[0].side_a.inner_from_a))
+ inner_from_b=factory.ContainerAttribute(lambda obj, containers: containers[0].side_a.inner_from_a))
outer = OuterMostFactory.build()
self.assertEqual(outer.foo, 30)