- Nothing changed yet.
- Fix declaration corruption bug when a factory defined foo__bar__baz=1 and a caller provided a foo__bar=x parameter at call time: this got merged into the factory’s base declarations.
- Fix packaging issues (see https://github.com/zestsoftware/zest.releaser/issues/212)
- Don’t crash when debugging PostGenerationDeclaration
This version brings massive changes to the core engine, thus reducing the number of corner cases and weird behaviourrs.
- issue #275: factory.fuzzy and factory.faker now use the same random seed.
factory.Maybe, which chooses among two possible declarations based on another field’s value (powers the
PostGenerationMethodCallonly allows to pass one positional argument; use keyword arguments for extra parameters.
- factory.fuzzy.get_random_state is deprecated, factory.random.get_random_state should be used instead.
- factory.fuzzy.set_random_state is deprecated, factory.random.set_random_state should be used instead.
- factory.fuzzy.reseed_random is deprecated, factory.random.reseed_random should be used instead.
- Fix packaging issues.
- issue #334: Adjust for the package change in
- issue #278: Formally drop support for Python2.6
Version 2.7.0 moves all error classes to factory.errors. This breaks existing import statements for any error classes except those importing FactoryError directly from the factory module.
factory.FactoryOptions.renameto help handle conflicting names (issue #206)
- Add support for random-yet-realistic values through fake-factory, through the
factory.Iteratorno longer begins iteration of its argument at import time, thus allowing to pass in a lazy iterator such as a Django queryset (i.e
- Simplify imports for ORM layers, now available through a simple
- issue #201: Properly handle custom Django managers when dealing with abstract Django models.
- issue #212: Fix
factory.django.mute_signals()to handle Django’s signal caching
- issue #228: Don’t load
- issue #219: Stop using
mogo.model.Model.new(), deprecated 4 years ago.
- Add support for Django 1.7/1.8
- Add support for mongoengine>=0.9.0 / pymongo>=2.1
- Add support for getting/setting
factory.fuzzy‘s random state (see issue #175, issue #185).
- Support lazy evaluation of iterables in
factory.fuzzy.FuzzyChoice(see issue #184).
- Support non-default databases at the factory level (see issue #171)
factory.django.ImageFieldnon-post_generation, i.e normal fields also available in
save()(see issue #141).
- Remove deprecated features from 2.4.0 (2014-06-21)
- Remove the auto-magical sequence setup (based on the latest primary key value in the database) for Django and SQLAlchemy; this relates to issues issue #170, issue #153, issue #111, issue #103, issue #92, issue #78. See https://github.com/FactoryBoy/factory_boy/commit/13d310f for technical details.
Version 2.5.0 removes the ‘auto-magical sequence setup’ bug-and-feature. This could trigger some bugs when tests expected a non-zero sequence reference.
Version 2.5.0 removes features that were marked as deprecated in v2.4.0.
FACTORY_*-style attributes are now declared in a
class Meta: section:
# Old-style, deprecated class MyFactory(factory.Factory): FACTORY_FOR = models.MyModel FACTORY_HIDDEN_ARGS = ['a', 'b', 'c'] # New-style class MyFactory(factory.Factory): class Meta: model = models.MyModel exclude = ['a', 'b', 'c']
A simple shell command to upgrade the code would be:
# sed -i: inplace update # grep -l: only file names, not matching lines sed -i 's/FACTORY_FOR =/class Meta:\n model =/' $(grep -l FACTORY_FOR $(find . -name '*.py'))
This takes care of all
FACTORY_FOR occurrences; the files containing other attributes to rename can be found with
grep -R FACTORY .
- Fix overriding deeply inherited attributes (set in one factory, overridden in a subclass, used in a sub-sub-class).
FACTORYclass-level attributes is deprecated and will be removed in 2.5. Those attributes should now declared within the
- Fixed sequence counter for
DjangoModelFactorywhen a factory inherits from another factory relating to an abstract model.
- Removed duplicated
- Properly handle sequences within object inheritance chains. If FactoryA inherits from FactoryB, and their associated classes share the same link, sequence counters will be shared (issue #93)
- Properly handle nested
FuzzyDatethanks to saulshanabrook
- Add a
factory_parentattribute to the
LazyAttribute, in order to access fields defined in wrapping factories.
MogoFactoryto their own modules (
- Add the
Factoryto ease resetting the sequence counter for a given factory.
- Add debug messages to
- Add a
- Add support for the SQLAlchemy ORM through
SQLAlchemyModelFactory(issue #64, thanks to Romain Commandé)
factory.django.ImageFieldhooks for related Django model fields (issue #52)
FACTORY_DJANGO_GET_OR_CREATEis empty, use
- Don’t push
FACTORY_DJANGO_GET_OR_CREATEis not set.
- Allow overriding the base factory class for
- Add support for Python3 (Thanks to kmike and nkryptic)
- The default
- Fields listed in
FACTORY_HIDDEN_ARGSwon’t be passed to the associated class’ constructor
- Add support for
- Add support for
Sequencecounter can be overridden when calling a generating function
Listdeclarations (Closes issue #18).
- Remove associated class discovery
extract_prefixkwarg to post-generation hooks.
- Stop defaulting to Django’s
Foo.objects.create()when “creating” instances
- Remove STRATEGY_*
This version deprecates many magic or unexplicit features that will be removed in v2.0.0.
Please read the Upgrading section, then run your
python -W default to see all remaining warnings.
SubFactoryto solve circular dependencies between factories
SelfAttributeto handle “container” attribute fetching
- Add a
Iteratormay be prevented from cycling by setting its
- Allow overriding default arguments in a
PostGenerationMethodCallwhen generating an instance of the factory
- An object created by a
DjangoModelFactorywill be saved again after
The following features have been deprecated and will be removed in an upcoming release.
- Usage of
set_building_function()are now deprecated
- Implicit associated class discovery is no longer supported, you must set the
FACTORY_FORattribute on all
- Usage of
This version deprecates a few magic or undocumented features. All warnings will turn into errors starting from v2.0.0.
In order to upgrade client code, apply the following rules:
- Add a
FACTORY_FORattribute pointing to the target class to each
Factory, instead of relying on automagic associated class discovery
- When using factory_boy for Django models, have each factory inherit from
factory.set_building_function(SomeFactory, building_function)with an override of the
factory.set_creation_function(SomeFactory, creation_function)with an override of the
CircularSubFactoryto solve circular dependencies between factories
PostGenerationDeclarationand derived classes.
- Fix packaging rules
- Allow classmethod/staticmethod on factories
- Auto-discovery of
FACTORY_FORbased on class name is now deprecated
- Improve the algorithm for populating a
python setup.py testcommand to run the test suite
- Allow custom build functions
- Add support for inheriting from multiple
Factoryclasses can now be declared
Sequencecounter starts at the next free database id
SelfAttribute, a shortcut for
factory.LazyAttribute(lambda o: o.foo.bar.baz.
- Improve handling of custom build/create functions
- First version of factory_boy
- Initial version by Mark Sandstrom (2010)
- Developed by Raphaël Barrois since 2011