diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-01-12 23:11:58 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-01-12 23:11:58 +0100 |
commit | 0c4b9334c93170ce6df17506f48e3937090aec05 (patch) | |
tree | e8666590751fc8075a2fa0a76c0b0da5711e62f9 | |
parent | 74225f59761ed3e09b625d9886552bdafb0fc30d (diff) | |
download | factory-boy-0c4b9334c93170ce6df17506f48e3937090aec05.tar factory-boy-0c4b9334c93170ce6df17506f48e3937090aec05.tar.gz |
Rename LazyContainerAttibute to ContainerAttribute.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
-rw-r--r-- | factory/__init__.py | 4 | ||||
-rw-r--r-- | factory/declarations.py | 12 | ||||
-rw-r--r-- | tests/test_using.py | 4 |
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) |