| Commit message (Collapse) | Author | Age |
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
No need to wrap it in a lambda to strip the object argument from LazyAttribute or the sequence argument from Sequence.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
As pointed by @glinmac.
|
|
|
|
|
| |
This disables the ``FACTORY_FOR`` syntax and related parameters,
that should be declared through ``class Meta``.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Thanks to @Dhekke for the help!
|
| |
|
| |
|
|
|
|
|
|
| |
Use less conflict-prone factory_related_name.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Magic abuse is bad.
|
|
|
|
| |
Replace CircularSubFactory('module', 'symbol') with SubFactory('module.symbol').
|
|
|
|
| |
Use Iterator/iterator instead.
|
|
|
|
|
|
|
| |
This provides a consistent behaviour for extracting arguments to
a PostGenerationMethodCall.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
Use it in DjangoModelFactory to save objects again if a post_generation hook ran.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
|
|
| |
This works exactly as for SubFactory.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
|
|
| |
Introduces a new, call-less syntax for the @post_generation decorator.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
|
|
| |
With a very simple syntax.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
|
|
| |
access to attributes from its parent.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|
|
|
|
| |
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
|