summaryrefslogtreecommitdiff
path: root/factory/declarations.py
Commit message (Collapse)AuthorAge
* Add Traits (Closes #251).Raphaël Barrois2016-04-02
| | | | | | Based on a boolean flag, those will alter the definitions of the current factory, taking precedence over pre-defined behavior but overridden by callsite-level arguments.
* Add a new Params section to factories.Raphaël Barrois2016-04-02
| | | | | | | | | | | | This handles parameters that alter the declarations of a factory. A few technical notes: - A parameter's outcome may alter other parameters - In order to fix that, we perform a (simple) cyclic definition detection at class declaration time. - Parameters may only be either naked values or ComplexParameter subclasses - Parameters are never passed to the underlying class
* factory: LazyFunction to just call a function in the simplest caseHervé Cauwelier2016-02-12
| | | | No need to wrap it in a lambda to strip the object argument from LazyAttribute or the sequence argument from Sequence.
* Add lazy loading to factory.Iterator.Raphaël Barrois2015-05-24
| | | | | | | | | | | factory.Iterator no longers begins iteration of its argument on declaration, since this behavior may trigger database query when that argument is, for instance, a Django queryset. The ``factory.Iterator``'s argument will only be called when the containing ``Factory`` is first evaluated; this means that factories using ``factory.Iterator(models.MyThingy.objects.all())`` will no longer call the database at import time.
* Update header years.Raphaël Barrois2015-03-26
|
* Logs: Allow non-integer sequences (Closes #148).Raphaël Barrois2015-03-03
| | | | As pointed by @glinmac.
* Remove deprecated features.Raphaël Barrois2014-11-18
| | | | | This disables the ``FACTORY_FOR`` syntax and related parameters, that should be declared through ``class Meta``.
* Rename 'target' to 'model'.Raphaël Barrois2014-05-18
|
* Pass attribute name to PostGenerationDeclarationRaphaël Barrois2013-06-15
|
* Cleanup PostGenerationDeclaration extraction context.Raphaël Barrois2013-06-15
|
* Add Iterator.reset() (Closes #63).Raphaël Barrois2013-06-15
|
* Properly handle passed-in None in RelatedFactory (Closes #62).Raphaël Barrois2013-06-14
| | | | Thanks to @Dhekke for the help!
* Add logging calls (Closes #45).Raphaël Barrois2013-06-14
|
* Factor lazy Factory import code.Raphaël Barrois2013-06-10
|
* declarations: Rename RelatedFactory.name (See #58).Raphaël Barrois2013-04-29
| | | | | | Use less conflict-prone factory_related_name. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add Dict/List declarations (Closes #18).Raphaël Barrois2013-04-15
|
* Pylint.Raphaël Barrois2013-04-03
|
* internal: merge OrderedDeclaration.evaluate() variants.Raphaël Barrois2013-04-03
|
* declarations: minor code simplificationRaphaël Barrois2013-04-02
|
* Default Sequence.type to int (Closes #50).Raphaël Barrois2013-03-24
|
* Add full Python 3 compatibility (Closes #10, #20, #49).nkryptic2013-03-15
| | | | | | | | Also: - update travis.yml to build against 2.6-2.7 and 3.2-3.3 - Switch to relative imports Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Remove extract_prefix from post-generation hooks.Raphaël Barrois2013-03-11
| | | | Magic abuse is bad.
* Remove CircularSubFactory.Raphaël Barrois2013-03-11
| | | | Replace CircularSubFactory('module', 'symbol') with SubFactory('module.symbol').
* Remove InfiniteIterator and infinite_iterator.Raphaël Barrois2013-03-11
| | | | Use Iterator/iterator instead.
* Cleanup argument extraction in PostGenMethod (See #36).Raphaël Barrois2013-03-05
| | | | | | | This provides a consistent behaviour for extracting arguments to a PostGenerationMethodCall. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Use extracted argument in PostGenerationMethodCall.Chris Lasher2013-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset makes it possible possible to override the default method arguments (or "method_args") passed in when instantiating PostGenerationMethodCall. Now the user can override the default arguments to the method called during post-generation when instantiating a factory. For example, using this UserFactory, class UserFactory(factory.Factory): FACTORY_FOR = User username = factory.Sequence(lambda n: 'user{0}'.format(n)) password = factory.PostGenerationMethodCall( 'set_password', None, 'defaultpassword') by default, the user will have a password set to 'defaultpassword', but this can be overridden by passing in a new password as a keyword argument: >>> u = UserFactory() >>> u.check_password('defaultpassword') True >>> other_u = UserFactory(password='different') >>> other_u.check_password('defaultpassword') False >>> other_u.check_password('different') True This changeset introduces a testing dependency on the Mock package http://pypi.python.org/pypi/mock. While this is a third-party dependency in Python 2, it is part of the Python 3 standard library, as unit.mock, and so a reasonable dependency to satisfy. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add a 'after post_generation' hook to Factory.Raphaël Barrois2013-03-04
| | | | | | Use it in DjangoModelFactory to save objects again if a post_generation hook ran. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Allow symbol names in RelatedFactory (Closes #30).Raphaël Barrois2013-03-03
| | | | | | This works exactly as for SubFactory. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Deprecate the extract_prefix option to PostGeneration.Raphaël Barrois2013-03-03
| | | | | | Introduces a new, call-less syntax for the @post_generation decorator. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Improve Iterator and SubFactory declarations.Raphaël Barrois2013-03-03
| | | | | | | | | | | | * Iterator now cycles by default * Iterator can be provided with a custom getter * SubFactory accepts a factory import path as well Deprecates: * InfiniteIterator * CircularSubFactory Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Happy New Year!Raphaël Barrois2013-01-02
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Mix SelfAttribute with ContainerAttribute.Raphaël Barrois2012-11-15
| | | | | | With a very simple syntax. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* [py3] Various python3-compatibility fixes.Raphaël Barrois2012-11-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Improve test coverage.Raphaël Barrois2012-08-16
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Introduce 'CircularSubFactory.Raphaël Barrois2012-08-09
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Fix PostGenerationDeclaration.extract.Raphaël Barrois2012-07-09
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Fix sequence count for SubFactory (Closes #16).Raphaël Barrois2012-06-01
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
* Typo in PostGenerationMethodCall.__init__ (Closes #14).Raphaël Barrois2012-05-02
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
* Rename post_declaration to post_generation.Raphaël Barrois2012-04-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
* Handle the PostGeneration declarations.Raphaël Barrois2012-04-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
* Add basis for PostGenerationDeclarationRaphaël Barrois2012-04-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
* Add the Iterator and InfiniteIterator attribute kinds.Raphaël Barrois2012-02-24
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Improve the 'SelfAttribute' syntax.v1.1.0Raphaël Barrois2012-02-24
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Improve documentation.Raphaël Barrois2012-02-24
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Allow using '__' in factory.SelfAttribute.Raphaël Barrois2012-02-24
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Rename LazyContainerAttibute to ContainerAttribute.Raphaël Barrois2012-01-12
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add support for 'LazyContainerAttribute', when a SubFactory field needs ↵Raphaël Barrois2012-01-12
| | | | | | access to attributes from its parent. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Cleanup 'factory.declarations'.Raphaël Barrois2011-12-21
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add encoding header.Raphaël Barrois2011-12-21
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Update copyrights.Raphaël Barrois2011-12-21
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>