ChangeLog¶
2.4.1 (2014-06-23)¶
Bugfix:
Fix overriding deeply inherited attributes (set in one factory, overridden in a subclass, used in a sub-sub-class).
2.4.0 (2014-06-21)¶
New:
Add support for
factory.fuzzy.FuzzyInteger.step, thanks to ilya-pirogov (issue #120)Add
mute_signals()decorator to temporarily disable some signals, thanks to ilya-pirogov (issue #122)Add
FuzzyFloat(issue #124)Declare target model and other non-declaration fields in a
class Metasection.
Deprecation:
Use of
FACTORY_FORand otherFACTORYclass-level attributes is deprecated and will be removed in 2.5. Those attributes should now declared within theclass Metaattribute:For
factory.Factory:
Rename
FACTORY_FORtomodelRename
FACTORY_FORtomodelRename
ABSTRACT_FACTORYtoabstractRename
FACTORY_STRATEGYtostrategyRename
FACTORY_ARG_PARAMETERStoinline_argsRename
FACTORY_HIDDEN_ARGStoexcludeFor
factory.django.DjangoModelFactory:For
factory.alchemy.SQLAlchemyModelFactory:
Rename
FACTORY_SESSIONtosqlalchemy_session
2.3.1 (2014-01-22)¶
Bugfix:
Fix badly written assert containing state-changing code, spotted by chsigi (issue #126)
Don’t crash when handling objects whose __repr__ is non-pure-ascii bytes on Py2, discovered by mbertheau (issue #123) and strycore (issue #127)
2.3.0 (2013-12-25)¶
New:
Add
FuzzyDecimal, thanks to thedrow (issue #94)Add support for
EmbeddedDocument, thanks to imiric (issue #100)
2.2.1 (2013-09-24)¶
Bugfix:
Fixed sequence counter for
DjangoModelFactorywhen a factory inherits from another factory relating to an abstract model.
2.2.0 (2013-09-24)¶
Bugfix:
Removed duplicated
SQLAlchemyModelFactorylurking infactory(issue #83)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
SubFactoryoverrides
New:
The
DjangoModelFactorynow supports theFACTORY_FOR = 'myapp.MyModel'syntax, making it easier to shove all factories in a single module (issue #66).Add
factory.debug()helper for easier backtrace analysisAdding factory support for mongoengine with
MongoEngineFactory.
2.1.2 (2013-08-14)¶
New:
The
ABSTRACT_FACTORYkeyword is now optional, and automatically set toTrueif neither theFactorysubclass nor its parent declare theFACTORY_FORattribute (issue #74)
2.1.1 (2013-07-02)¶
Bugfix:
Properly retrieve the
colorkeyword argument passed toImageField
2.1.0 (2013-06-26)¶
New:
Add
FuzzyDatethanks to saulshanabrookAdd
FuzzyDateTimeandFuzzyNaiveDateTime.Add a
factory_parentattribute to theLazyStubpassed toLazyAttribute, in order to access fields defined in wrapping factories.Move
DjangoModelFactoryandMogoFactoryto their own modules (factory.djangoandfactory.mogo)Add the
reset_sequence()classmethod toFactoryto ease resetting the sequence counter for a given factory.Add debug messages to
factorylogger.Add support for the SQLAlchemy ORM through
SQLAlchemyModelFactory(issue #64, thanks to Romain Commandé)Add
factory.django.FileFieldandfactory.django.ImageFieldhooks for related Django model fields (issue #52)
Bugfix
Properly handle non-integer pks in
DjangoModelFactory(issue #57).Disable
RelatedFactorygeneration when a specific value was passed (issue #62, thanks to Gabe Koscky)
Deprecation:
Rename
RelatedFactory’snameargument tofactory_related_name(See issue #58)
2.0.2 (2013-04-16)¶
New:
When
FACTORY_DJANGO_GET_OR_CREATEis empty, useModel.objects.create()instead ofModel.objects.get_or_create.
2.0.1 (2013-04-16)¶
New:
Don’t push
defaultstoget_or_createwhenFACTORY_DJANGO_GET_OR_CREATEis not set.
2.0.0 (2013-04-15)¶
New:
Allow overriding the base factory class for
make_factory()and friends.The default
typeforSequenceis nowintFields listed in
FACTORY_HIDDEN_ARGSwon’t be passed to the associated class’ constructorAdd support for
get_or_createinDjangoModelFactory, throughFACTORY_DJANGO_GET_OR_CREATE.Add support for
fuzzyattribute definitions.The
Sequencecounter can be overridden when calling a generating function
Removed:
Remove associated class discovery
Remove
InfiniteIteratorandinfinite_iterator()Remove
CircularSubFactoryRemove
extract_prefixkwarg to post-generation hooks.Stop defaulting to Django’s
Foo.objects.create()when “creating” instancesRemove STRATEGY_*
Remove
set_building_function()/set_creation_function()
1.3.0 (2013-03-11)¶
Warning
This version deprecates many magic or unexplicit features that will be removed in v2.0.0.
Please read the Upgrading section, then run your
tests with python -W default to see all remaining warnings.
New¶
- Global:
Rewrite the whole documentation
Provide a dedicated
MogoFactorysubclass ofFactory
- The Factory class:
Better creation/building customization hooks at
factory.Factory._build()andfactory.Factory.create()Add support for passing non-kwarg parameters to a
Factorywrapped class throughFACTORY_ARG_PARAMETERS.Keep the
FACTORY_FORattribute inFactoryclasses
- Declarations:
Allow
SubFactoryto solve circular dependencies between factoriesEnhance
SelfAttributeto handle “container” attribute fetchingA
Iteratormay be prevented from cycling by setting itscycleargument toFalseAllow overriding default arguments in a
PostGenerationMethodCallwhen generating an instance of the factoryAn object created by a
DjangoModelFactorywill be saved again afterPostGenerationhooks execution
Pending deprecation¶
The following features have been deprecated and will be removed in an upcoming release.
- Declarations:
InfiniteIteratoris deprecated in favor ofIteratorCircularSubFactoryis deprecated in favor ofSubFactoryThe
extract_prefixargument topost_generation()is now deprecated
- Factory:
Usage of
set_creation_function()andset_building_function()are now deprecatedImplicit associated class discovery is no longer supported, you must set the
FACTORY_FORattribute on allFactorysubclasses
Upgrading¶
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 eachFactory, instead of relying on automagic associated class discoveryWhen using factory_boy for Django models, have each factory inherit from
DjangoModelFactoryReplace
factory.CircularSubFactory('some.module', 'Symbol')withfactory.SubFactory('some.module.Symbol')Replace
factory.InfiniteIterator(iterable)withfactory.Iterator(iterable)Replace
@factory.post_generation()with@factory.post_generationReplace
factory.set_building_function(SomeFactory, building_function)with an override of the_build()method ofSomeFactoryReplace
factory.set_creation_function(SomeFactory, creation_function)with an override of the_create()method ofSomeFactory
1.2.0 (2012-09-08)¶
New:
Add
CircularSubFactoryto solve circular dependencies between factories
1.1.5 (2012-07-09)¶
Bugfix:
Fix
PostGenerationDeclarationand derived classes.
1.1.4 (2012-06-19)¶
New:
Add
use_strategy()decorator to override aFactory’s default strategyImprove test running (tox, python2.6/2.7)
Introduce
PostGenerationandRelatedFactory
1.1.3 (2012-03-09)¶
Bugfix:
Fix packaging rules
1.1.2 (2012-02-25)¶
New:
Add
IteratorandInfiniteIteratorforFactoryattribute declarations.Provide
generate()andsimple_generate(), that allow specifying the instantiation strategy directly. Also providesgenerate_batch()andsimple_generate_batch().
1.1.1 (2012-02-24)¶
New:
Add
build_batch(),create_batch()andstub_batch(), to instantiate factories in batch
1.1.0 (2012-02-24)¶
New:
Improve the
SelfAttributesyntax to fetch sub-attributes using thefoo.barsyntax;Add
ContainerAttributeto fetch attributes from the container of aSubFactory.Provide the
make_factory()helper:MyClassFactory = make_factory(MyClass, x=3, y=4)
Bugfix:
Allow classmethod/staticmethod on factories
Deprecation:
Auto-discovery of
FACTORY_FORbased on class name is now deprecated
1.0.4 (2011-12-21)¶
New:
Improve the algorithm for populating a
Factoryattributes dictAdd
python setup.py testcommand to run the test suiteAllow custom build functions
Introduce
MOGO_BUILDbuild functionAdd support for inheriting from multiple
FactoryProvide
DjangoModelFactory, whoseSequencecounter starts at the next free database idIntroduce
SelfAttribute, a shortcut forfactory.LazyAttribute(lambda o: o.foo.bar.baz.
Bugfix:
Handle nested
SubFactoryShare sequence counter between parent and subclasses
Fix
SubFactory/Sequenceinterferences
1.0.2 (2011-05-16)¶
New:
Introduce
SubFactory
1.0.1 (2011-05-13)¶
New:
Allow
FactoryinheritanceImprove handling of custom build/create functions
Bugfix:
Fix concurrency between
LazyAttributeandSequence
1.0.0 (2010-08-22)¶
New:
First version of factory_boy
Credits¶
Initial version by Mark Sandstrom (2010)
Developed by Raphaël Barrois since 2011