NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #764 most downloaded on PyPI
A versatile test fixtures replacement based on thoughtbot's factory_bot for Ruby.
Last release 2 years ago
no release in 18 months
Ships fairly regularly
a new release about every 8 months
Nearly every release is documented
notes for 46 of 46 stable releases
Nothing withdrawn
no release was ever pulled
16 years old
46 releases · first in 2010
New: - Publish type annotations
New:
Publish type annotations
Bugfix: - Fix docs generation New: - Add support for Python 3.13
Bugfix:
Fix docs generation
New:
Add support for Python 3.13
- issue 903 : Add basic typing annotations
One column per quarter.
New:
Add support for Django 4.2
Add support for Django 5.1
Add support for Python 3.12
issue 903 : Add basic typing annotations
Run the test suite against mongomock instead of an actual MongoDB server
Bugfix:
issue 1031 : Do not require sqlalchemy_session when sqlalchemy_session_factory is provided.
Removed:
Stop advertising and verifying support for Django 3.2, 4.0, 4.1
New:
Add support for Django 4.2
Add support for Django 5.1
Add support for Python 3.12
903: Add basic typing annotations
Run the test suite against mongomock instead of an actual MongoDB server
Bugfix:
1031: Do not require ~factory.alchemy.SQLAlchemyOptions.sqlalchemy_session when ~factory.alchemy.SQLAlchemyOptions.sqlalchemy_session_factory is provided.
Removed:
Stop advertising and verifying support for Django 3.2, 4.0, 4.1
To help with the transition, factory.django.DjangoModelFactory ’s _after_postgeneration raises a DeprecationWarning when calling save() . Inspect your…
New:
issue 366 : Add factory.django.Password to generate Django User passwords.
issue 304 : Add sqlalchemy_session_factory to dynamically create sessions for use by the SQLAlchemyModelFactory .
Add support for Django 4.0
Add support for Django 4.1
Add support for Python 3.10
Add support for Python 3.11
Bugfix:
Make mute_signals() mute signals during post-generation.
issue 775 : Change the signature for SQLAlchemyModelFactory ’s _save and _get_or_create methods to avoid argument names clashes with a field named session .
Deprecated:
DjangoModelFactory will stop issuing a second call to save() on the created instance when Post-generation hooks return a value.
To help with the transition, factory.django.DjangoModelFactory ’s _after_postgeneration raises a DeprecationWarning when calling save() . Inspect your DjangoModelFactory subclasses:
If the save() call is not needed after PostGeneration , set factory.django.DjangoOptions.skip_postgeneration_save to True in the factory meta.
Otherwise, the instance has been modified by PostGeneration hooks and needs to be save() d. Either:
call django.db.models.Model.save() in the PostGeneration hook that modifies the instance, or
override the _after_postgeneration method to save() the instance.
Removed:
Drop support for Django 2.2
Drop support for Django 3.0
Drop support for Django 3.1
Drop support for Python 3.6
Drop support for Python 3.7
New:
366: Add factory.django.Password to generate Django ~django.contrib.auth.models.User passwords.
304: Add ~factory.alchemy.SQLAlchemyOptions.sqlalchemy_session_factory to dynamically create sessions for use by the ~factory.alchemy.SQLAlchemyModelFactory.
Add support for Django 4.0
Add support for Django 4.1
Add support for Python 3.10
Add support for Python 3.11
Bugfix:
Make ~factory.django.mute_signals mute signals during post-generation.
775: Change the signature for ~factory.alchemy.SQLAlchemyModelFactory's _save and _get_or_create methods to avoid argument names clashes with a field named session.
Deprecated:
~factory.django.DjangoModelFactory will stop issuing a second call to ~django.db.models.Model.save on the created instance when post-generation-hooks return a value.
To help with the transition, factory.django.DjangoModelFactory's _after_postgeneration raises a DeprecationWarning when calling ~django.db.models.Model.save. Inspect your ~factory.django.DjangoModelFactory subclasses:
If the ~django.db.models.Model.save call is not needed after ~factory.PostGeneration, set factory.django.DjangoOptions.skip_postgeneration_save to True in the factory meta.
Otherwise, the instance has been modified by ~factory.PostGeneration hooks and needs to be ~django.db.models.Model.saved. Either:
call django.db.models.Model.save in the ~factory.PostGeneration hook that modifies the instance, or
override the ~factory.Factory._after_postgeneration method to ~django.db.models.Model.save the instance.
Removed:
Drop support for Django 2.2
Drop support for Django 3.0
Drop support for Django 3.1
Drop support for Python 3.6
Drop support for Python 3.7
New: - Add support for Django 3.2
Add support for Django 3.2
Bugfix:
Do not override signals receivers registered in a mute_signals() context.
issue 775 : Change the signature for SQLAlchemyModelFactory ’s _save and _get_or_create methods to avoid argument names clashes with a field named session .
Add support for Django 3.2
Bugfix:
Do not override signals receivers registered in a ~factory.django.mute_signals context.
775: Change the signature for ~factory.alchemy.SQLAlchemyModelFactory's _save and _get_or_create methods to avoid argument names clashes with a field named session.
- Drop support for Django 1.11. This version is not maintained anymore .
New:
Add support for Django 3.1
Add support for Python 3.9
Removed:
Drop support for Django 1.11. This version is not maintained anymore .
Drop support for Python 3.5. This version is not maintained anymore .
Deprecated:
factory.use_strategy() . Use factory.FactoryOptions.strategy instead. The purpose of use_strategy() duplicates the factory option. Follow PEP 20 : There should be one– and preferably only one –obvious way to do it.
use_strategy() will be removed in the next major version.
Bug fix:
issue 785 issue 786 issue 787 issue 788 issue 790 issue 796 : Calls to factory.Faker and factory.django.FileField within a Trait or Maybe no longer lead to a KeyError crash.
New:
Add support for Django 3.1
Add support for Python 3.9
Removed:
Drop support for Django 1.11. This version is not maintained anymore.
Drop support for Python 3.5. This version is not maintained anymore.
Deprecated:
factory.use_strategy. Use factory.FactoryOptions.strategy instead. The purpose of ~factory.use_strategy duplicates the factory option. Follow 20: There should be one-- and preferably only one --obvious way to do it.
~factory.use_strategy() will be removed in the next major version.
Bug fix:
785 786 787 788 790 796: Calls to factory.Faker and factory.django.FileField within a ~factory.Trait or ~factory.Maybe no longer lead to a KeyError crash.
- Allow all types of declarations in factory.Faker calls - enables references to other faker-defined attributes.
New:
Allow all types of declarations in factory.Faker calls - enables references to other faker-defined attributes.
- issue 769 : Fix import factory; factory.django.DjangoModelFactory and similar calls.
Bug fix:
issue 769 : Fix import factory; factory.django.DjangoModelFactory and similar calls.
- Remove deprecated force_flush from SQLAlchemyModelFactory options. Use sqlalchemy_session_persistence = "flush" instead.
The following aliases were removed:
+================================================+===================================================+ | Broken alias | New import | +================================================+===================================================+ | from factory import DjangoModelFactory | from factory.django import DjangoModelFactory | +————————————————+—————————————————+ | from factory import MogoFactory | from factory.mogo import MogoFactory | +————————————————+—————————————————+ | from factory.fuzzy import get_random_state | from factory.random import get_random_state | +————————————————+—————————————————+ | from factory.fuzzy import set_random_state | from factory.random import set_random_state | +————————————————+—————————————————+ | from factory.fuzzy import reseed_random | from factory.random import reseed_random | +================================================+===================================================+
Removed:
Drop support for Python 2 and 3.4. These versions are not maintained anymore .
Drop support for Django 2.0 and 2.1. These versions are not maintained anymore .
Remove deprecated force_flush from SQLAlchemyModelFactory options. Use sqlalchemy_session_persistence = "flush" instead.
Drop deprecated attributes() from Factory subclasses; use factory.make_factory(dict, FactoryClass._meta.pre_declarations) instead.
Drop deprecated declarations() from Factory subclasses; use FactoryClass._meta.pre_declarations instead.
Drop factory.compat module.
New:
Add support for Python 3.8
Add support for Django 2.2 and 3.0
Report misconfiguration when a Factory is used as the model for another Factory .
Allow configuring the color palette of ImageField .
get_random_state() now represents the state of Faker and factory_boy fuzzy attributes.
Add SQLAlchemy get_or_create support
Improvements:
issue 561 : Display a developer-friendly error message when providing a model instead of a factory in a SubFactory class.
Bug fix:
Fix issue with SubFactory not preserving signal muting behavior of the used factory, thanks Patrick Stein .
Fix issue with overriding parameters in a Trait, thanks Grégoire Rocher .
issue 598 : Limit get_or_create behavior to fields specified in django_get_or_create .
issue 606 : Re-raise IntegrityError when django_get_or_create with multiple fields fails to lookup model using user provided keyword arguments.
issue 630 : TypeError masked by repr AttributeError when initializing Maybe with inconsistent phases.
- Add getter to FuzzyChoice that mimics the behavior of getter in Iterator
New:
Add support for Python 3.7
Add support for Django 2.1
Add getter to FuzzyChoice that mimics the behavior of getter in Iterator
Make the extra_kwargs parameter of Faker ’s generate method optional
Add RelatedFactoryList class for one-to-many support, thanks Sean Harrington .
Make the locale argument for Faker keyword-only
Bug fix:
Allow renamed arguments to be optional, thanks to Justin Crown .
Fix django_get_or_create behavior when using multiple fields with unique=True , thanks to @YPCrumble https://github.com/YPCrumble
New:
Add support for Python 3.7
Add support for Django 2.1
Add getter to ~factory.fuzzy.FuzzyChoice that mimics the behavior of getter in ~factory.Iterator
Make the extra_kwargs parameter of ~factory.Faker's generate method optional
Add ~factory.RelatedFactoryList class for one-to-many support, thanks Sean Harrington.
Make the locale argument for ~factory.Faker keyword-only
Bug fix:
Allow renamed arguments to be optional, thanks to Justin Crown.
Fix django_get_or_create behavior when using multiple fields with unique=True, thanks to @YPCrumble <https://github.com/YPCrumble>
- Fix passing deep context to a SubFactory ( Foo(x__y__z=factory.Faker('name') )
Bug fix:
Fix passing deep context to a SubFactory ( Foo(x__y__z=factory.Faker('name') )
Bug fix:
Fix passing deep context to a ~factory.SubFactory (Foo(x__y__z=factory.Faker('name'))
- Fix FuzzyFloat to return a 15 decimal digits precision float by default
Bug fix:
Fix FuzzyFloat to return a 15 decimal digits precision float by default
issue 451 : Restore FileField to a factory.declarations.ParameteredAttribute , relying on composition to parse the provided parameters.
issue 389 : Fix random state management with faker .
issue 466 : Restore mixing Trait and post_generation() .
Bug fix:
Fix ~factory.fuzzy.FuzzyFloat to return a 15 decimal digits precision float by default
451: Restore ~factory.django.FileField to a factory.declarations.ParameteredAttribute, relying on composition to parse the provided parameters.
389: Fix random state management with faker.
466: Restore mixing ~factory.Trait and ~factory.post_generation.
- issue 443 : Don’t crash when calling factory.Iterator.reset() on a brand new iterator.
Bug fix:
issue 443 : Don’t crash when calling factory.Iterator.reset() on a brand new iterator.
New:
issue 397 : Allow a factory.Maybe to contain a PostGeneration declaration. This also applies to factory.Trait , since they use a factory.Maybe declaration internally.
Bug fix:
443: Don't crash when calling factory.Iterator.reset() on a brand new iterator.
New:
397: Allow a factory.Maybe to contain a ~factory.PostGeneration declaration. This also applies to factory.Trait, since they use a factory.Maybe declaration internally.
- 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 int
Bug fix:
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 )
Bug fix:
Fix packaging issues (see https://github.com/zestsoftware/zest.releaser/issues/212 )
Don’t crash when debugging PostGenerationDeclaration
Bug fix:
Fix packaging issues (see https://github.com/zestsoftware/zest.releaser/issues/212)
Don't crash when debugging PostGenerationDeclaration
- factory.fuzzy.get_random_state is deprecated, factory.random.get_random_state should be used instead.
This version brings massive changes to the core engine, thus reducing the number of corner cases and weird behaviors.
New:
issue 275 : factory.fuzzy and factory.faker now use the same random seed.
Add factory.Maybe , which chooses among two possible declarations based on another field’s value (powers the Trait feature).
PostGenerationMethodCall only allows to pass one positional argument; use keyword arguments for extra parameters.
Deprecation:
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.
Bug fix: - Fix packaging issues.
Bug fix:
Fix packaging issues.
- issue 240 : Call post-generation declarations in the order they were declared, thanks to Oleg Pidsadnyi .
New:
issue 240 : Call post-generation declarations in the order they were declared, thanks to Oleg Pidsadnyi .
issue 309 : Provide new options for SQLAlchemy session persistence
Bug fix:
issue 334 : Adjust for the package change in faker
- pull request 267 : Add factory.LazyFunction to remove unneeded lambda parameters, thanks to Hervé Cauwelier .
New:
pull request 267 : Add factory.LazyFunction to remove unneeded lambda parameters, thanks to Hervé Cauwelier .
issue 251 : Add parameterized factories and traits
pull request 256 , pull request 292 : Improve error messages in corner cases
Removed:
pull request 278 : Formally drop support for Python2.6
Warning
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.
- pull request 262 : Allow optional forced flush on SQLAlchemy, courtesy of Minjung .
New:
pull request 262 : Allow optional forced flush on SQLAlchemy, courtesy of Minjung .
New:
262: Allow optional forced flush on SQLAlchemy, courtesy of Minjung.
- pull request 219 : Stop using mogo.model.Model.new() , deprecated 4 years ago.
New:
Add factory.FactoryOptions.rename to help handle conflicting names ( issue 206 )
Add support for random-yet-realistic values through fake-factory , through the factory.Faker class.
factory.Iterator no longer begins iteration of its argument at import time, thus allowing to pass in a lazy iterator such as a Django queryset (i.e factory.Iterator(models.MyThingy.objects.all()) ).
Simplify imports for ORM layers, now available through a simple factory import, at factory.alchemy.SQLAlchemyModelFactory / factory.django.DjangoModelFactory / factory.mongoengine.MongoEngineFactory .
Bug fix:
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 django.apps.apps.get_model() until required
pull request 219 : Stop using mogo.model.Model.new() , deprecated 4 years ago.
- Add support for Django 1.7/1.8
Bug fix:
Add support for Django 1.7/1.8
Add support for mongoengine>=0.9.0 / pymongo>=2.1
Bug fix:
Add support for Django 1.7/1.8
Add support for mongoengine>=0.9.0 / pymongo>=2.1
- Respect custom managers in DjangoModelFactory (see issue 192 )
Bug fix:
Respect custom managers in DjangoModelFactory (see issue 192 )
Allow passing declarations (e.g Sequence ) as parameters to FileField and ImageField .
Bug fix:
Respect custom managers in ~factory.django.DjangoModelFactory (see 192)
Allow passing declarations (e.g ~factory.Sequence) as parameters to ~factory.django.FileField and ~factory.django.ImageField.
- Remove deprecated features from 2.4.0 (2014-06-21)
New:
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 )
Make factory.django.FileField and factory.django.ImageField non-post_generation, i.e normal fields also available in save() (see issue 141 ).
Bug fix:
Avoid issues when using factory.django.mute_signals() on a base factory class (see issue 183 ).
Fix limitations of factory.StubFactory , that can now use factory.SubFactory and co (see issue 131 ).
Deprecation:
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.
Warning
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.
Warning
Version 2.5.0 removes features that were marked as deprecated in v2.4.0 .
All FACTORY_* -style attributes are now declared in a class Meta: section:
A simple shell command to upgrade the code would be:
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).
Bug fix:
Fix overriding deeply inherited attributes (set in one factory, overridden in a subclass, used in a sub-sub-class).
Bug fix:
Fix overriding deeply inherited attributes (set in one factory, overridden in a subclass, used in a sub-sub-class).
- Use of FACTORY_FOR and other FACTORY class-level attributes is deprecated and will be removed in 2.5. Those attributes should now declared within th…
New:
Add support for factory.fuzzy.FuzzyInteger.step , thanks to ilya-pirogov ( pull request 120 )
Add mute_signals() decorator to temporarily disable some signals, thanks to ilya-pirogov ( pull request 122 )
Add FuzzyFloat ( issue 124 )
Declare target model and other non-declaration fields in a class Meta section.
Deprecation:
Use of FACTORY_FOR and other FACTORY class-level attributes is deprecated and will be removed in 2.5. Those attributes should now declared within the class Meta attribute:
For factory.Factory :
Rename factory.Factory.FACTORY_FOR to model
Rename factory.Factory.ABSTRACT_FACTORY to abstract
Rename factory.Factory.FACTORY_STRATEGY to strategy
Rename factory.Factory.FACTORY_ARG_PARAMETERS to inline_args
Rename factory.Factory.FACTORY_HIDDEN_ARGS to exclude
For factory.django.DjangoModelFactory :
Rename factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE to django_get_or_create
For factory.alchemy.SQLAlchemyModelFactory :
Rename factory.alchemy.SQLAlchemyModelFactory.FACTORY_SESSION to sqlalchemy_session
New:
Add support for factory.fuzzy.FuzzyInteger.step, thanks to ilya-pirogov (120)
Add ~factory.django.mute_signals decorator to temporarily disable some signals, thanks to ilya-pirogov (122)
Add ~factory.fuzzy.FuzzyFloat (124)
Declare target model and other non-declaration fields in a class Meta section.
Deprecation:
Use of FACTORY_FOR and other FACTORY class-level attributes is deprecated and will be removed in 2.5. Those attributes should now declared within the class Meta attribute:
For factory.Factory:
Rename factory.Factory.FACTORY_FOR to ~factory.FactoryOptions.model
Rename factory.Factory.ABSTRACT_FACTORY to ~factory.FactoryOptions.abstract
Rename factory.Factory.FACTORY_STRATEGY to ~factory.FactoryOptions.strategy
Rename factory.Factory.FACTORY_ARG_PARAMETERS to ~factory.FactoryOptions.inline_args
Rename factory.Factory.FACTORY_HIDDEN_ARGS to ~factory.FactoryOptions.exclude
For factory.django.DjangoModelFactory:
Rename factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE to ~factory.django.DjangoOptions.django_get_or_create
For factory.alchemy.SQLAlchemyModelFactory:
Rename factory.alchemy.SQLAlchemyModelFactory.FACTORY_SESSION to ~factory.alchemy.SQLAlchemyOptions.sqlalchemy_session
- Fix badly written assert containing state-changing code, spotted by chsigi ( pull request 126 )
Bug fix:
Fix badly written assert containing state-changing code, spotted by chsigi ( pull request 126 )
Don’t crash when handling objects whose repr is non-pure-ASCII bytes on Python 2, discovered by mbertheau ( issue 123 ) and strycore ( pull request 127 )
- Add FuzzyText , thanks to jdufresne ( pull request 97 )
New:
Add FuzzyText , thanks to jdufresne ( pull request 97 )
Add FuzzyDecimal , thanks to thedrow ( pull request 94 )
Add support for EmbeddedDocument , thanks to imiric ( pull request 100 )
- Fixed sequence counter for DjangoModelFactory when a factory inherits from another factory relating to an abstract model.
Bug fix:
Fixed sequence counter for DjangoModelFactory when a factory inherits from another factory relating to an abstract model.
Bug fix:
Fixed sequence counter for ~factory.django.DjangoModelFactory when a factory inherits from another factory relating to an abstract model.
- Removed duplicated SQLAlchemyModelFactory lurking in factory ( pull request 83 )
Bug fix:
Removed duplicated SQLAlchemyModelFactory lurking in factory ( pull request 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 SubFactory overrides
New:
The DjangoModelFactory now supports the FACTORY_FOR = 'myapp.MyModel' syntax, making it easier to shove all factories in a single module ( issue 66 ).
Add factory.debug() helper for easier backtrace analysis
Adding factory support for mongoengine with MongoEngineFactory .
Bug fix:
Removed duplicated ~factory.alchemy.SQLAlchemyModelFactory lurking in factory (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 (93)
Properly handle nested ~factory.SubFactory overrides
New:
The ~factory.django.DjangoModelFactory now supports the FACTORY_FOR = 'myapp.MyModel' syntax, making it easier to shove all factories in a single module (66).
Add factory.debug() helper for easier backtrace analysis
Adding factory support for mongoengine with ~factory.mongoengine.MongoEngineFactory.
- The factory.Factory.ABSTRACT_FACTORY keyword is now optional, and automatically set to True if neither the Factory subclass nor its parent declare t
New:
The factory.Factory.ABSTRACT_FACTORY keyword is now optional, and automatically set to True if neither the Factory subclass nor its parent declare the factory.Factory.FACTORY_FOR attribute ( issue 74 )
New:
The factory.Factory.ABSTRACT_FACTORY keyword is now optional, and automatically set to True if neither the ~factory.Factory subclass nor its parent declare the factory.Factory.FACTORY_FOR attribute (74)
- Properly retrieve the color keyword argument passed to ImageField
Bug fix:
Properly retrieve the color keyword argument passed to ImageField
Bug fix:
Properly retrieve the color keyword argument passed to ~factory.django.ImageField
- Add FuzzyDate thanks to saulshanabrook
New:
Add FuzzyDate thanks to saulshanabrook
Add FuzzyDateTime and FuzzyNaiveDateTime .
Add a factory_parent attribute to the factory.builder.Resolver passed to LazyAttribute , in order to access fields defined in wrapping factories.
Move DjangoModelFactory and MogoFactory to their own modules ( factory.django and factory.mogo )
Add the reset_sequence() classmethod to Factory to ease resetting the sequence counter for a given factory.
Add debug messages to factory logger.
Add a reset() method to Iterator ( issue 63 )
Add support for the SQLAlchemy ORM through SQLAlchemyModelFactory ( pull request 64 , thanks to Romain Commandé )
Add factory.django.FileField and factory.django.ImageField hooks for related Django model fields ( issue 52 )
Bug fix
Properly handle non-integer primary keys in DjangoModelFactory ( issue 57 ).
Disable RelatedFactory generation when a specific value was passed ( issue 62 , thanks to Gabe Koscky )
Deprecation:
Rename RelatedFactory ’s name argument to factory_related_name (See issue 58 )
New:
Add ~factory.fuzzy.FuzzyDate thanks to saulshanabrook
Add ~factory.fuzzy.FuzzyDateTime and ~factory.fuzzy.FuzzyNaiveDateTime.
Add a factory_parent attribute to the factory.builder.Resolver passed to ~factory.LazyAttribute, in order to access fields defined in wrapping factories.
Move ~factory.django.DjangoModelFactory and ~factory.mogo.MogoFactory to their own modules (factory.django and factory.mogo)
Add the ~factory.Factory.reset_sequence classmethod to ~factory.Factory to ease resetting the sequence counter for a given factory.
Add debug messages to factory logger.
Add a ~factory.Iterator.reset method to ~factory.Iterator (63)
Add support for the SQLAlchemy ORM through ~factory.alchemy.SQLAlchemyModelFactory (64, thanks to Romain Commandé)
Add factory.django.FileField and factory.django.ImageField hooks for related Django model fields (52)
Bug fix
Properly handle non-integer primary keys in ~factory.django.DjangoModelFactory (57).
Disable ~factory.RelatedFactory generation when a specific value was passed (62, thanks to Gabe Koscky)
Deprecation:
Rename ~factory.RelatedFactory's name argument to factory_related_name (See 58)
- When factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is empty, use Model.objects.create() instead of Model.objects.get_or_create .
New:
When factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is empty, use Model.objects.create() instead of Model.objects.get_or_create .
New:
When factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is empty, use Model.objects.create() instead of Model.objects.get_or_create.
- Don’t push defaults to get_or_create when factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is not set.
New:
Don’t push defaults to get_or_create when factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is not set.
New:
Don't push defaults to get_or_create when factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is not set.
- Allow overriding the base factory class for make_factory() and friends.
New:
Allow overriding the base factory class for make_factory() and friends.
Add support for Python3 (Thanks to kmike and nkryptic )
The default type for Sequence is now int
Fields listed in factory.Factory.FACTORY_HIDDEN_ARGS won’t be passed to the associated class’ constructor
Add support for get_or_create in DjangoModelFactory , through factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE .
Add support for fuzzy attribute definitions.
The Sequence counter can be overridden when calling a generating function
Add Dict and List declarations (Closes issue 18 ).
Removed:
Remove associated class discovery
Remove factory.InfiniteIterator and factory.infinite_iterator
Remove factory.CircularSubFactory
Remove extract_prefix kwarg to post-generation hooks.
Stop defaulting to Django’s Foo.objects.create() when “creating” instances
Remove STRATEGY_*
Remove factory.Factory.set_building_function / factory.Factory.set_creation_function
New:
Allow overriding the base factory class for ~factory.make_factory and friends.
The default type for ~factory.Sequence is now int
Fields listed in factory.Factory.FACTORY_HIDDEN_ARGS won't be passed to the associated class' constructor
Add support for get_or_create in ~factory.django.DjangoModelFactory, through factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE.
Add support for ~factory.fuzzy attribute definitions.
The Sequence counter can be overridden when calling a generating function
Add ~factory.Dict and ~factory.List declarations (Closes 18).
Removed:
Remove associated class discovery
Remove factory.InfiniteIterator and factory.infinite_iterator
Remove factory.CircularSubFactory
Remove extract_prefix kwarg to post-generation hooks.
Stop defaulting to Django's Foo.objects.create() when "creating" instances
Remove STRATEGY_*
Remove factory.Factory.set_building_function / factory.Factory.set_creation_function
This version deprecates many magic or unexplicit features that will be removed in v2.0.0.
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.
Rewrite the whole documentation
Provide a dedicated MogoFactory subclass of Factory
Better creation/building customization hooks at factory.Factory._build() and factory.Factory.create()
Add support for passing non-kwarg parameters to a Factory wrapped class through FACTORY_ARG_PARAMETERS .
Keep the FACTORY_FOR attribute in Factory classes
Allow SubFactory to solve circular dependencies between factories
Enhance SelfAttribute to handle “container” attribute fetching
Add a getter to Iterator declarations
A Iterator may be prevented from cycling by setting its cycle argument to False
Allow overriding default arguments in a PostGenerationMethodCall when generating an instance of the factory
An object created by a DjangoModelFactory will be saved again after PostGeneration hooks execution
The following features have been deprecated and will be removed in an upcoming release.
factory.InfiniteIterator is deprecated in favor of Iterator
factory.CircularSubFactory is deprecated in favor of SubFactory
The extract_prefix argument to post_generation() is now deprecated
Usage of factory.Factory.set_creation_function and factory.Factory.set_building_function are now deprecated
Implicit associated class discovery is no longer supported, you must set the FACTORY_FOR attribute on all Factory subclasses
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_FOR attribute pointing to the target class to each Factory , instead of relying on automatic associated class discovery
When using factory_boy for Django models, have each factory inherit from DjangoModelFactory
Replace factory.CircularSubFactory('some.module', 'Symbol') with factory.SubFactory('some.module.Symbol')
Replace factory.InfiniteIterator(iterable) with factory.Iterator(iterable)
Replace @factory.post_generation() with @factory.post_generation
Replace factory.set_building_function(SomeFactory, building_function) with an override of the _build() method of SomeFactory
Replace factory.set_creation_function(SomeFactory, creation_function) with an override of the _create() method of SomeFactory
Warning
This version deprecates many magic or unexplicit features that will be removed in v2.0.0.
Please read the changelog-1-3-0-upgrading section, then run your tests with python -W default to see all remaining warnings.
Rewrite the whole documentation
Provide a dedicated ~factory.mogo.MogoFactory subclass of ~factory.Factory
Better creation/building customization hooks at factory.Factory._build and factory.Factory.create
Add support for passing non-kwarg parameters to a ~factory.Factory wrapped class through FACTORY_ARG_PARAMETERS.
Keep the FACTORY_FOR attribute in ~factory.Factory classes
Allow ~factory.SubFactory to solve circular dependencies between factories
Enhance ~factory.SelfAttribute to handle "container" attribute fetching
Add a ~factory.Iterator.getter to ~factory.Iterator declarations
A ~factory.Iterator may be prevented from cycling by setting its ~factory.Iterator.cycle argument to False
Allow overriding default arguments in a ~factory.PostGenerationMethodCall when generating an instance of the factory
An object created by a ~factory.django.DjangoModelFactory will be saved again after ~factory.PostGeneration hooks execution
The following features have been deprecated and will be removed in an upcoming release.
factory.InfiniteIterator is deprecated in favor of ~factory.Iterator
factory.CircularSubFactory is deprecated in favor of ~factory.SubFactory
The extract_prefix argument to ~factory.post_generation is now deprecated
Usage of factory.Factory.set_creation_function and factory.Factory.set_building_function are now deprecated
Implicit associated class discovery is no longer supported, you must set the FACTORY_FOR attribute on all ~factory.Factory subclasses
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_FOR attribute pointing to the target class to each ~factory.Factory, instead of relying on automatic associated class discovery
When using factory_boy for Django models, have each factory inherit from ~factory.django.DjangoModelFactory
Replace factory.CircularSubFactory('some.module', 'Symbol') with factory.SubFactory('some.module.Symbol')
Replace factory.InfiniteIterator(iterable) with factory.Iterator(iterable)
Replace @factory.post_generation() with @factory.post_generation
Replace factory.set_building_function(SomeFactory, building_function) with an override of the ~factory.Factory._build method of SomeFactory
Replace factory.set_creation_function(SomeFactory, creation_function) with an override of the ~factory.Factory._create method of SomeFactory
- Add factory.CircularSubFactory to solve circular dependencies between factories
New:
Add factory.CircularSubFactory to solve circular dependencies between factories
New:
Add factory.CircularSubFactory to solve circular dependencies between factories
- Fix factory.PostGenerationDeclaration and derived classes.
Bug fix:
Fix factory.PostGenerationDeclaration and derived classes.
- Add use_strategy() decorator to override a Factory ’s default strategy
New:
Add use_strategy() decorator to override a Factory ’s default strategy
Improve test running (tox, python2.6/2.7)
Introduce PostGeneration and RelatedFactory
New:
Add ~factory.use_strategy decorator to override a ~factory.Factory's default strategy
Improve test running (tox, python2.6/2.7)
Introduce ~factory.PostGeneration and ~factory.RelatedFactory
Bug fix: - Fix packaging rules
Bug fix:
Fix packaging rules
- Add Iterator and factory.InfiniteIterator for Factory attribute declarations.
New:
Add Iterator and factory.InfiniteIterator for Factory attribute declarations.
Provide generate() and simple_generate() , that allow specifying the instantiation strategy directly. Also provides generate_batch() and simple_generate_batch() .
New:
Add ~factory.Iterator and factory.InfiniteIterator for ~factory.Factory attribute declarations.
Provide ~factory.Factory.generate and ~factory.Factory.simple_generate, that allow specifying the instantiation strategy directly. Also provides ~factory.Factory.generate_batch and ~factory.Factory.simple_generate_batch.
- Add build_batch() , create_batch() and stub_batch() , to instantiate factories in batch
New:
Add build_batch() , create_batch() and stub_batch() , to instantiate factories in batch
New:
Add ~factory.Factory.build_batch, ~factory.Factory.create_batch and ~factory.Factory.stub_batch, to instantiate factories in batch
- Auto-discovery of factory.Factory.FACTORY_FOR based on class name is now deprecated
New:
Improve the SelfAttribute syntax to fetch sub-attributes using the foo.bar syntax;
Add factory.ContainerAttribute to fetch attributes from the container of a SubFactory .
Provide the make_factory() helper: MyClassFactory = make_factory(MyClass, x=3, y=4)
Add build() , create() , stub() helpers
Bug fix:
Allow classmethod / staticmethod on factories
Deprecation:
Auto-discovery of factory.Factory.FACTORY_FOR based on class name is now deprecated
New:
Improve the ~factory.SelfAttribute syntax to fetch sub-attributes using the foo.bar syntax;
Add factory.ContainerAttribute to fetch attributes from the container of a ~factory.SubFactory.
Provide the ~factory.make_factory helper: MyClassFactory = make_factory(MyClass, x=3, y=4)
Add ~factory.build, ~factory.create, ~factory.stub helpers
Bug fix:
Allow classmethod/staticmethod on factories
Deprecation:
Auto-discovery of factory.Factory.FACTORY_FOR based on class name is now deprecated
- Improve the algorithm for populating a Factory attributes dict
New:
Improve the algorithm for populating a Factory attributes dict
Add python setup.py test command to run the test suite
Allow custom build functions
Introduce factory.MOGO_BUILD build function
Add support for inheriting from multiple Factory
Base Factory classes can now be declared abstract through factory.Factory.ABSTRACT_FACTORY .
Provide DjangoModelFactory , whose Sequence counter starts at the next free database id
Introduce SelfAttribute , a shortcut for factory.LazyAttribute(lambda o: o.foo.bar.baz .
Bug fix:
Handle nested SubFactory
Share sequence counter between parent and subclasses
Fix SubFactory / Sequence interference
New:
Improve the algorithm for populating a ~factory.Factory attributes dict
Add python setup.py test command to run the test suite
Allow custom build functions
Introduce factory.MOGO_BUILD build function
Add support for inheriting from multiple ~factory.Factory
Base ~factory.Factory classes can now be declared abstract through factory.Factory.ABSTRACT_FACTORY.
Provide ~factory.django.DjangoModelFactory, whose ~factory.Sequence counter starts at the next free database id
Introduce ~factory.SelfAttribute, a shortcut for factory.LazyAttribute(lambda o: o.foo.bar.baz.
Bug fix:
Handle nested ~factory.SubFactory
Share sequence counter between parent and subclasses
Fix ~factory.SubFactory / ~factory.Sequence interference
New: - First version of factory_boy
New:
First version of factory_boy
Your coding agent can read these notes before it upgrades. Set up the MCP server →