Skip to content

Latest commit

 

History

History
670 lines (427 loc) · 22.1 KB

changelog.rst

File metadata and controls

670 lines (427 loc) · 22.1 KB

ChangeLog

2.11.1 (2018-05-05)

Bugfix:

  • Fix passing deep context to a ~factory.SubFactory (Foo(x__y__z=factory.Faker('name'))

2.11.0 (2018-05-05)

Bugfix:

  • 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.

2.10.0 (2018-01-28)

Bugfix:

  • 443: Don't crash when calling factory.Iterator.reset() on a brand new iterator.

New:

  • 397: Allow a factory.Maybe to contain a ~factory.PostGenerationDeclaration. This also applies to factory.Trait, since they use a factory.Maybe declaration internally.

2.9.2 (2017-08-03)

Bugfix:

  • 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.

2.9.1 (2017-08-02)

Bugfix:

2.9.0 (2017-07-30)

This version brings massive changes to the core engine, thus reducing the number of corner cases and weird behaviourrs.

New:

  • 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 ~factory.Trait feature).
  • ~factory.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.

2.8.1 (2016-12-17)

Bugfix:

  • Fix packaging issues.

2.8.0 (2016-12-17)

New:

  • 240: Call post-generation declarations in the order they were declared, thanks to Oleg Pidsadnyi.
  • 309: Provide new options for SQLAlchemy session persistence

Bugfix:

  • 334: Adjust for the package change in faker

2.7.0 (2016-04-19)

New:

  • 267: Add factory.LazyFunction to remove unneeded lambda parameters, thanks to Hervé Cauwelier.
  • 251: Add parameterized factories <parameters> and traits <factory.Trait>
  • 256, 292: Improve error messages in corner cases

Removed:

  • 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.

2.6.1 (2016-02-10)

New:

  • 262: Allow optional forced flush on SQLAlchemy, courtesy of Minjung.

2.6.0 (2015-10-20)

New:

  • Add factory.FactoryOptions.rename to help handle conflicting names (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.

Bugfix:

  • 201: Properly handle custom Django managers when dealing with abstract Django models.
  • 212: Fix factory.django.mute_signals to handle Django's signal caching
  • 228: Don't load django.apps.apps.get_model() until required
  • 219: Stop using mogo.model.Model.new(), deprecated 4 years ago.

2.5.2 (2015-04-21)

Bugfix:

  • Add support for Django 1.7/1.8
  • Add support for mongoengine>=0.9.0 / pymongo>=2.1

2.5.1 (2015-03-27)

Bugfix:

  • 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.

2.5.0 (2015-03-26)

New:

  • Add support for getting/setting factory.fuzzy's random state (see 175, 185).
  • Support lazy evaluation of iterables in factory.fuzzy.FuzzyChoice (see 184).
  • Support non-default databases at the factory level (see 171)
  • Make factory.django.FileField and factory.django.ImageField non-post_generation, i.e normal fields also available in save() (see 141).

Bugfix:

  • Avoid issues when using factory.django.mute_signals on a base factory class (see 183).
  • Fix limitations of factory.StubFactory, that can now use factory.SubFactory and co (see 131).

Deprecation:

  • Remove deprecated features from v2.4.0
  • Remove the auto-magical sequence setup (based on the latest primary key value in the database) for Django and SQLAlchemy; this relates to issues 170, 153, 111, 103, 92, 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.

Upgrading

Warning

Version 2.5.0 removes features that were marked as deprecated in v2.4.0 <v2.4.0>.

All 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 .

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 (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 <factory.FactoryOptions> 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

2.3.1 (2014-01-22)

Bugfix:

  • Fix badly written assert containing state-changing code, spotted by chsigi (126)
  • Don't crash when handling objects whose __repr__ is non-pure-ascii bytes on Py2, discovered by mbertheau (123) and strycore (127)

2.3.0 (2013-12-25)

New:

  • Add ~factory.fuzzy.FuzzyText, thanks to jdufresne (97)
  • Add ~factory.fuzzy.FuzzyDecimal, thanks to thedrow (94)
  • Add support for ~mongoengine.EmbeddedDocument, thanks to imiric (100)

2.2.1 (2013-09-24)

Bugfix:

  • Fixed sequence counter for ~factory.django.DjangoModelFactory when a factory inherits from another factory relating to an abstract model.

2.2.0 (2013-09-24)

Bugfix:

  • 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.

2.1.2 (2013-08-14)

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)

2.1.1 (2013-07-02)

Bugfix:

  • Properly retrieve the color keyword argument passed to ~factory.django.ImageField

2.1.0 (2013-06-26)

New:

  • Add ~factory.fuzzy.FuzzyDate thanks to saulshanabrook
  • Add ~factory.fuzzy.FuzzyDateTime and ~factory.fuzzy.FuzzyNaiveDateTime.
  • Add a ~factory.builder.Resolver.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)

Bugfix

  • Properly handle non-integer pks 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)

2.0.2 (2013-04-16)

New:

  • When ~factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is empty, use Model.objects.create() instead of Model.objects.get_or_create.

2.0.1 (2013-04-16)

New:

  • Don't push defaults to get_or_create when ~factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE is not set.

2.0.0 (2013-04-15)

New:

  • Allow overriding the base factory class for ~factory.make_factory and friends.
  • Add support for Python3 (Thanks to kmike and nkryptic)
  • The default ~factory.Sequence.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

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 changelog-1-3-0-upgrading section, then run your tests with python -W default to see all remaining warnings.

New

  • Global:
    • Rewrite the whole documentation
    • Provide a dedicated ~factory.mogo.MogoFactory subclass of ~factory.Factory
  • The Factory class:
    • 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.Factory.FACTORY_ARG_PARAMETERS.
    • Keep the ~factory.Factory.FACTORY_FOR attribute in ~factory.Factory classes
  • Declarations:
    • 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

Pending deprecation

The following features have been deprecated and will be removed in an upcoming release.

  • Declarations:
    • ~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
  • Factory:
    • 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.Factory.FACTORY_FOR attribute on all ~factory.Factory subclasses

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_FOR attribute pointing to the target class to each ~factory.Factory, instead of relying on automagic 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

1.2.0 (2012-09-08)

New:

  • Add ~factory.CircularSubFactory to solve circular dependencies between factories

1.1.5 (2012-07-09)

Bugfix:

  • Fix ~factory.PostGenerationDeclaration and derived classes.

1.1.4 (2012-06-19)

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

1.1.3 (2012-03-09)

Bugfix:

  • Fix packaging rules

1.1.2 (2012-02-25)

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.

1.1.1 (2012-02-24)

New:

  • Add ~factory.Factory.build_batch, ~factory.Factory.create_batch and ~factory.Factory.stub_batch, to instantiate factories in batch

1.1.0 (2012-02-24)

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

Bugfix:

  • Allow classmethod/staticmethod on factories

Deprecation:

  • Auto-discovery of ~factory.Factory.FACTORY_FOR based on class name is now deprecated

1.0.4 (2011-12-21)

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 <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.

Bugfix:

  • Handle nested ~factory.SubFactory
  • Share sequence counter between parent and subclasses
  • Fix ~factory.SubFactory / ~factory.Sequence interferences

1.0.2 (2011-05-16)

New:

  • Introduce ~factory.SubFactory

1.0.1 (2011-05-13)

New:

  • Allow ~factory.Factory inheritance
  • Improve handling of custom build/create functions

Bugfix:

  • Fix concurrency between ~factory.LazyAttribute and ~factory.Sequence

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