1ChangeLog 2========= 3 4.. Note for v4.x: don't forget to check "Deprecated" sections for removal. 5 63.2.1 (2021-10-26) 7------------------ 8 9*New:* 10 11 - Add support for Django 3.2 12 13*Bugfix:* 14 15 - Do not override signals receivers registered in a :meth:`~factory.django.mute_signals` context. 16 17 - :issue:`775`: Change the signature for :meth:`~factory.alchemy.SQLAlchemyModelFactory._save` and 18 :meth:`~factory.alchemy.SQLAlchemyModelFactory._get_or_create` to avoid argument names clashes with a field named 19 ``session``. 20 21 223.2.0 (2020-12-28) 23------------------ 24 25*New:* 26 27 - Add support for Django 3.1 28 - Add support for Python 3.9 29 30*Removed:* 31 32 - Drop support for Django 1.11. This version `is not maintained anymore <https://www.djangoproject.com/download/#supported-versions>`__. 33 - Drop support for Python 3.5. This version `is not maintained anymore <https://devguide.python.org/devcycle/#end-of-life-branches>`__. 34 35*Deprecated:* 36 37 - :func:`factory.use_strategy`. Use :attr:`factory.FactoryOptions.strategy` instead. 38 The purpose of :func:`~factory.use_strategy` duplicates the factory option. Follow :pep:`20`: *There should be 39 one-- and preferably only one --obvious way to do it.* 40 41 :func:`~factory.use_strategy()` will be removed in the next major version. 42 43*Bug fix:* 44 45 - :issue:`785` :issue:`786` :issue:`787` :issue:`788` :issue:`790` :issue:`796`: Calls to :class:`factory.Faker` 46 and :class:`factory.django.FileField` within a :class:`~factory.Trait` or :class:`~factory.Maybe` no longer lead to 47 a ``KeyError`` crash. 48 49 503.1.0 (2020-10-02) 51------------------ 52 53*New:* 54 55 - Allow all types of declarations in :class:`factory.Faker` calls - enables references to other faker-defined attributes. 56 57 583.0.1 (2020-08-13) 59------------------ 60 61*Bug fix:* 62 63 - :issue:`769`: Fix ``import factory; factory.django.DjangoModelFactory`` and similar calls. 64 65 663.0.0 (2020-08-12) 67------------------ 68 69Breaking changes 70"""""""""""""""" 71 72The following aliases were removed: 73 74+------------------------------------------------+---------------------------------------------------+ 75| Broken alias | New import | 76+================================================+===================================================+ 77| ``from factory import DjangoModelFactory`` | ``from factory.django import DjangoModelFactory`` | 78+------------------------------------------------+---------------------------------------------------+ 79| ``from factory import MogoFactory`` | ``from factory.mogo import MogoFactory`` | 80+------------------------------------------------+---------------------------------------------------+ 81| ``from factory.fuzzy import get_random_state`` | ``from factory.random import get_random_state`` | 82+------------------------------------------------+---------------------------------------------------+ 83| ``from factory.fuzzy import set_random_state`` | ``from factory.random import set_random_state`` | 84+------------------------------------------------+---------------------------------------------------+ 85| ``from factory.fuzzy import reseed_random`` | ``from factory.random import reseed_random`` | 86+------------------------------------------------+---------------------------------------------------+ 87 88*Removed:* 89 90 - Drop support for Python 2 and 3.4. These versions `are not maintained anymore <https://devguide.python.org/devcycle/#end-of-life-branches>`__. 91 - Drop support for Django 2.0 and 2.1. These versions `are not maintained anymore <https://www.djangoproject.com/download/#supported-versions>`__. 92 - Remove deprecated ``force_flush`` from ``SQLAlchemyModelFactory`` options. Use 93 ``sqlalchemy_session_persistence = "flush"`` instead. 94 - Drop deprecated ``attributes()`` from :class:`~factory.Factory` subclasses; use 95 ``factory.make_factory(dict, FactoryClass._meta.pre_declarations)`` instead. 96 - Drop deprecated ``declarations()`` from :class:`~factory.Factory` subclasses; use ``FactoryClass._meta.pre_declarations`` instead. 97 - Drop ``factory.compat`` module. 98 99*New:* 100 101 - Add support for Python 3.8 102 - Add support for Django 2.2 and 3.0 103 - Report misconfiguration when a :py:class:`~factory.Factory` is used as the :py:attr:`~factory.Factory.model` for another :py:class:`~factory.Factory`. 104 - Allow configuring the color palette of :py:class:`~factory.django.ImageField`. 105 - :py:meth:`get_random_state()` now represents the state of Faker and ``factory_boy`` fuzzy attributes. 106 - Add SQLAlchemy ``get_or_create`` support 107 108*Improvements:* 109 110 - :issue:`561`: Display a developer-friendly error message when providing a model instead of a factory in a :class:`~factory.declarations.SubFactory` class. 111 112*Bug fix:* 113 114 - Fix issue with SubFactory not preserving signal muting behavior of the used factory, thanks `Patrick Stein <https://github.com/PFStein>`_. 115 - Fix issue with overriding parameters in a Trait, thanks `Grégoire Rocher <https://github.com/cecedille1>`_. 116 - :issue:`598`: Limit ``get_or_create`` behavior to fields specified in ``django_get_or_create``. 117 - :issue:`606`: Re-raise :class:`~django.db.IntegrityError` when ``django_get_or_create`` with multiple fields fails to lookup model using user provided keyword arguments. 118 - :issue:`630`: TypeError masked by __repr__ AttributeError when initializing ``Maybe`` with inconsistent phases. 119 120 1212.12.0 (2019-05-11) 122------------------- 123 124*New:* 125 126 - Add support for Python 3.7 127 - Add support for Django 2.1 128 - Add :attr:`~factory.fuzzy.FuzzyChoice.getter` to :class:`~factory.fuzzy.FuzzyChoice` that mimics 129 the behavior of ``getter`` in :class:`~factory.Iterator` 130 - Make the ``extra_kwargs`` parameter of :meth:`~factory.faker.Faker.generate` optional 131 - Add :class:`~factory.RelatedFactoryList` class for one-to-many support, thanks `Sean Harrington <https://github.com/seanharr11>`_. 132 - Make the `locale` argument for :class:`~factory.faker.Faker` keyword-only 133 134*Bug fix:* 135 136 - Allow renamed arguments to be optional, thanks to `Justin Crown <https://github.com/mrname>`_. 137 - Fix `django_get_or_create` behavior when using multiple fields with `unique=True`, thanks to `@YPCrumble <https://github.com/YPCrumble>` 138 139 1402.11.1 (2018-05-05) 141------------------- 142 143*Bug fix:* 144 145 - Fix passing deep context to a :class:`~factory.SubFactory` (``Foo(x__y__z=factory.Faker('name')``) 146 147 1482.11.0 (2018-05-05) 149------------------- 150 151*Bug fix:* 152 153 - Fix :class:`~factory.fuzzy.FuzzyFloat` to return a 15 decimal digits precision float by default 154 - :issue:`451`: Restore :class:`~factory.django.FileField` to a 155 :class:`~factory.declarations.ParameteredAttribute`, relying on composition to parse the provided parameters. 156 - :issue:`389`: Fix random state management with ``faker``. 157 - :issue:`466`: Restore mixing :class:`~factory.Trait` and :meth:`~factory.post_generation`. 158 159 1602.10.0 (2018-01-28) 161------------------- 162 163*Bug fix:* 164 165 - :issue:`443`: Don't crash when calling :meth:`factory.Iterator.reset()` on a brand new iterator. 166 167*New:* 168 169 - :issue:`397`: Allow a :class:`factory.Maybe` to contain a :class:`~factory.PostGenerationDeclaration`. 170 This also applies to :class:`factory.Trait`, since they use a :class:`factory.Maybe` declaration internally. 171 172.. _v2.9.2: 173 1742.9.2 (2017-08-03) 175------------------ 176 177*Bug fix:* 178 179 - Fix declaration corruption bug when a factory defined `foo__bar__baz=1` and a caller 180 provided a `foo__bar=x` parameter at call time: this got merged into the factory's base 181 declarations. 182 183.. _v2.9.1: 184 1852.9.1 (2017-08-02) 186------------------ 187 188*Bug fix:* 189 190 - Fix packaging issues (see https://github.com/zestsoftware/zest.releaser/issues/212) 191 - Don't crash when debugging PostGenerationDeclaration 192 193.. _v2.9.0: 194 1952.9.0 (2017-07-30) 196------------------ 197 198This version brings massive changes to the core engine, thus reducing the number of 199corner cases and weird behaviors. 200 201*New:* 202 203 - :issue:`275`: `factory.fuzzy` and `factory.faker` now use the same random seed. 204 - Add :class:`factory.Maybe`, which chooses among two possible declarations based 205 on another field's value (powers the :class:`~factory.Trait` feature). 206 - :class:`~factory.PostGenerationMethodCall` only allows to pass one positional argument; use keyword arguments for 207 extra parameters. 208 209*Deprecation:* 210 211 - `factory.fuzzy.get_random_state` is deprecated, `factory.random.get_random_state` should be used instead. 212 - `factory.fuzzy.set_random_state` is deprecated, `factory.random.set_random_state` should be used instead. 213 - `factory.fuzzy.reseed_random` is deprecated, `factory.random.reseed_random` should be used instead. 214 215.. _v2.8.1: 216 2172.8.1 (2016-12-17) 218------------------ 219 220*Bug fix:* 221 222 - Fix packaging issues. 223 224 225.. _v2.8.0: 226 2272.8.0 (2016-12-17) 228------------------ 229 230*New:* 231 232 - :issue:`240`: Call post-generation declarations in the order they were declared, 233 thanks to `Oleg Pidsadnyi <https://github.com/olegpidsadnyi>`_. 234 - :issue:`309`: Provide new options for SQLAlchemy session persistence 235 236*Bug fix:* 237 238 - :issue:`334`: Adjust for the package change in ``faker`` 239 240 241.. _v2.7.0: 242 2432.7.0 (2016-04-19) 244------------------ 245 246*New:* 247 248 - :pr:`267`: Add :class:`factory.LazyFunction` to remove unneeded lambda parameters, 249 thanks to `Hervé Cauwelier <https://github.com/bors-ltd>`_. 250 - :issue:`251`: Add :ref:`parameterized factories <parameters>` and :class:`traits <factory.Trait>` 251 - :pr:`256`, :pr:`292`: Improve error messages in corner cases 252 253*Removed:* 254 255 - :pr:`278`: Formally drop support for Python2.6 256 257.. warning:: Version 2.7.0 moves all error classes to 258 `factory.errors`. This breaks existing import statements 259 for any error classes except those importing 260 `FactoryError` directly from the `factory` module. 261 262.. _v2.6.1: 263 2642.6.1 (2016-02-10) 265------------------ 266 267*New:* 268 269 - :pr:`262`: Allow optional forced flush on SQLAlchemy, courtesy of `Minjung <https://github.com/Minjung>`_. 270 271.. _v2.6.0: 272 2732.6.0 (2015-10-20) 274------------------ 275 276*New:* 277 278 - Add :attr:`factory.FactoryOptions.rename` to help handle conflicting names (:issue:`206`) 279 - Add support for random-yet-realistic values through `fake-factory <https://pypi.org/project/fake-factory/>`_, 280 through the :class:`factory.Faker` class. 281 - :class:`factory.Iterator` no longer begins iteration of its argument at import time, 282 thus allowing to pass in a lazy iterator such as a Django queryset 283 (i.e ``factory.Iterator(models.MyThingy.objects.all())``). 284 - Simplify imports for ORM layers, now available through a simple ``factory`` import, 285 at ``factory.alchemy.SQLAlchemyModelFactory`` / ``factory.django.DjangoModelFactory`` / ``factory.mongoengine.MongoEngineFactory``. 286 287*Bug fix:* 288 289 - :issue:`201`: Properly handle custom Django managers when dealing with abstract Django models. 290 - :issue:`212`: Fix :meth:`factory.django.mute_signals` to handle Django's signal caching 291 - :issue:`228`: Don't load :func:`django.apps.apps.get_model()` until required 292 - :pr:`219`: Stop using :meth:`mogo.model.Model.new()`, deprecated 4 years ago. 293 294.. _v2.5.2: 295 2962.5.2 (2015-04-21) 297------------------ 298 299*Bug fix:* 300 301 - Add support for Django 1.7/1.8 302 - Add support for mongoengine>=0.9.0 / pymongo>=2.1 303 304.. _v2.5.1: 305 3062.5.1 (2015-03-27) 307------------------ 308 309*Bug fix:* 310 311 - Respect custom managers in :class:`~factory.django.DjangoModelFactory` (see :issue:`192`) 312 - Allow passing declarations (e.g :class:`~factory.Sequence`) as parameters to :class:`~factory.django.FileField` 313 and :class:`~factory.django.ImageField`. 314 315.. _v2.5.0: 316 3172.5.0 (2015-03-26) 318------------------ 319 320*New:* 321 322 - Add support for getting/setting :mod:`factory.fuzzy`'s random state (see :issue:`175`, :issue:`185`). 323 - Support lazy evaluation of iterables in :class:`factory.fuzzy.FuzzyChoice` (see :issue:`184`). 324 - Support non-default databases at the factory level (see :issue:`171`) 325 - Make :class:`factory.django.FileField` and :class:`factory.django.ImageField` non-post_generation, i.e normal fields also available in ``save()`` (see :issue:`141`). 326 327*Bug fix:* 328 329 - Avoid issues when using :meth:`factory.django.mute_signals` on a base factory class (see :issue:`183`). 330 - Fix limitations of :class:`factory.StubFactory`, that can now use :class:`factory.SubFactory` and co (see :issue:`131`). 331 332 333*Deprecation:* 334 335 - Remove deprecated features from :ref:`v2.4.0` 336 - Remove the auto-magical sequence setup (based on the latest primary key value in the database) for Django and SQLAlchemy; 337 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. 338 339.. warning:: Version 2.5.0 removes the 'auto-magical sequence setup' bug-and-feature. 340 This could trigger some bugs when tests expected a non-zero sequence reference. 341 342Upgrading 343""""""""" 344 345.. warning:: Version 2.5.0 removes features that were marked as deprecated in :ref:`v2.4.0 <v2.4.0>`. 346 347All ``FACTORY_*``-style attributes are now declared in a ``class Meta:`` section: 348 349.. code-block:: python 350 351 # Old-style, deprecated 352 class MyFactory(factory.Factory): 353 FACTORY_FOR = models.MyModel 354 FACTORY_HIDDEN_ARGS = ['a', 'b', 'c'] 355 356 # New-style 357 class MyFactory(factory.Factory): 358 class Meta: 359 model = models.MyModel 360 exclude = ['a', 'b', 'c'] 361 362A simple shell command to upgrade the code would be: 363 364.. code-block:: sh 365 366 # sed -i: inplace update 367 # grep -l: only file names, not matching lines 368 sed -i 's/FACTORY_FOR =/class Meta:\n model =/' $(grep -l FACTORY_FOR $(find . -name '*.py')) 369 370This takes care of all ``FACTORY_FOR`` occurrences; the files containing other attributes to rename can be found with ``grep -R FACTORY .`` 371 372 373.. _v2.4.1: 374 3752.4.1 (2014-06-23) 376------------------ 377 378*Bug fix:* 379 380 - Fix overriding deeply inherited attributes (set in one factory, overridden in a subclass, used in a sub-sub-class). 381 382.. _v2.4.0: 383 3842.4.0 (2014-06-21) 385------------------ 386 387*New:* 388 389 - Add support for :attr:`factory.fuzzy.FuzzyInteger.step`, thanks to `ilya-pirogov <https://github.com/ilya-pirogov>`_ (:pr:`120`) 390 - Add :meth:`~factory.django.mute_signals` decorator to temporarily disable some signals, thanks to `ilya-pirogov <https://github.com/ilya-pirogov>`_ (:pr:`122`) 391 - Add :class:`~factory.fuzzy.FuzzyFloat` (:issue:`124`) 392 - Declare target model and other non-declaration fields in a ``class Meta`` section. 393 394*Deprecation:* 395 396 - Use of ``FACTORY_FOR`` and other ``FACTORY`` class-level attributes is deprecated and will be removed in 2.5. 397 Those attributes should now declared within the :class:`class Meta <factory.FactoryOptions>` attribute: 398 399 For :class:`factory.Factory`: 400 401 * Rename :attr:`~factory.Factory.FACTORY_FOR` to :attr:`~factory.FactoryOptions.model` 402 * Rename :attr:`~factory.Factory.ABSTRACT_FACTORY` to :attr:`~factory.FactoryOptions.abstract` 403 * Rename :attr:`~factory.Factory.FACTORY_STRATEGY` to :attr:`~factory.FactoryOptions.strategy` 404 * Rename :attr:`~factory.Factory.FACTORY_ARG_PARAMETERS` to :attr:`~factory.FactoryOptions.inline_args` 405 * Rename :attr:`~factory.Factory.FACTORY_HIDDEN_ARGS` to :attr:`~factory.FactoryOptions.exclude` 406 407 For :class:`factory.django.DjangoModelFactory`: 408 409 * Rename :attr:`~factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE` to :attr:`~factory.django.DjangoOptions.django_get_or_create` 410 411 For :class:`factory.alchemy.SQLAlchemyModelFactory`: 412 413 * Rename :attr:`~factory.alchemy.SQLAlchemyModelFactory.FACTORY_SESSION` to :attr:`~factory.alchemy.SQLAlchemyOptions.sqlalchemy_session` 414 415.. _v2.3.1: 416 4172.3.1 (2014-01-22) 418------------------ 419 420*Bug fix:* 421 422 - Fix badly written assert containing state-changing code, spotted by `chsigi <https://github.com/chsigi>`_ (:pr:`126`) 423 - Don't crash when handling objects whose ``__repr__`` is non-pure-ASCII bytes on Python 2, 424 discovered by `mbertheau <https://github.com/mbertheau>`_ (:issue:`123`) and `strycore <https://github.com/strycore>`_ (:pr:`127`) 425 426.. _v2.3.0: 427 4282.3.0 (2013-12-25) 429------------------ 430 431*New:* 432 433 - Add :class:`~factory.fuzzy.FuzzyText`, thanks to `jdufresne <https://github.com/jdufresne>`_ (:pr:`97`) 434 - Add :class:`~factory.fuzzy.FuzzyDecimal`, thanks to `thedrow <https://github.com/thedrow>`_ (:pr:`94`) 435 - Add support for :class:`~mongoengine.EmbeddedDocument`, thanks to `imiric <https://github.com/imiric>`_ (:pr:`100`) 436 437.. _v2.2.1: 438 4392.2.1 (2013-09-24) 440------------------ 441 442*Bug fix:* 443 444 - Fixed sequence counter for :class:`~factory.django.DjangoModelFactory` when a factory 445 inherits from another factory relating to an abstract model. 446 447.. _v2.2.0: 448 4492.2.0 (2013-09-24) 450------------------ 451 452*Bug fix:* 453 454 - Removed duplicated :class:`~factory.alchemy.SQLAlchemyModelFactory` lurking in :mod:`factory` 455 (:pr:`83`) 456 - Properly handle sequences within object inheritance chains. 457 If ``FactoryA`` inherits from ``FactoryB``, and their associated classes 458 share the same link, sequence counters will be shared (:issue:`93`) 459 - Properly handle nested :class:`~factory.SubFactory` overrides 460 461*New:* 462 463 - The :class:`~factory.django.DjangoModelFactory` now supports the ``FACTORY_FOR = 'myapp.MyModel'`` 464 syntax, making it easier to shove all factories in a single module (:issue:`66`). 465 - Add :meth:`factory.debug()` helper for easier backtrace analysis 466 - Adding factory support for mongoengine with :class:`~factory.mongoengine.MongoEngineFactory`. 467 468.. _v2.1.2: 469 4702.1.2 (2013-08-14) 471------------------ 472 473*New:* 474 475 - The :class:`~factory.Factory.ABSTRACT_FACTORY` keyword is now optional, and automatically set 476 to ``True`` if neither the :class:`~factory.Factory` subclass nor its parent declare the 477 :class:`~factory.Factory.FACTORY_FOR` attribute (:issue:`74`) 478 479 480.. _v2.1.1: 481 4822.1.1 (2013-07-02) 483------------------ 484 485*Bug fix:* 486 487 - Properly retrieve the ``color`` keyword argument passed to :class:`~factory.django.ImageField` 488 489.. _v2.1.0: 490 4912.1.0 (2013-06-26) 492------------------ 493 494*New:* 495 496 - Add :class:`~factory.fuzzy.FuzzyDate` thanks to `saulshanabrook <https://github.com/saulshanabrook>`_ 497 - Add :class:`~factory.fuzzy.FuzzyDateTime` and :class:`~factory.fuzzy.FuzzyNaiveDateTime`. 498 - Add a :attr:`~factory.builder.Resolver.factory_parent` attribute to the 499 :class:`~factory.builder.Resolver` passed to :class:`~factory.LazyAttribute`, in order to access 500 fields defined in wrapping factories. 501 - Move :class:`~factory.django.DjangoModelFactory` and :class:`~factory.mogo.MogoFactory` 502 to their own modules (:mod:`factory.django` and :mod:`factory.mogo`) 503 - Add the :meth:`~factory.Factory.reset_sequence` classmethod to :class:`~factory.Factory` 504 to ease resetting the sequence counter for a given factory. 505 - Add debug messages to ``factory`` logger. 506 - Add a :meth:`~factory.Iterator.reset` method to :class:`~factory.Iterator` (:issue:`63`) 507 - Add support for the SQLAlchemy ORM through :class:`~factory.alchemy.SQLAlchemyModelFactory` 508 (:pr:`64`, thanks to `Romain Commandé <https://github.com/rcommande>`_) 509 - Add :class:`factory.django.FileField` and :class:`factory.django.ImageField` hooks for 510 related Django model fields (:issue:`52`) 511 512*Bug fix* 513 514 - Properly handle non-integer primary keys in :class:`~factory.django.DjangoModelFactory` (:issue:`57`). 515 - Disable :class:`~factory.RelatedFactory` generation when a specific value was 516 passed (:issue:`62`, thanks to `Gabe Koscky <https://github.com/dhekke>`_) 517 518*Deprecation:* 519 520 - Rename :class:`~factory.RelatedFactory`'s ``name`` argument to ``factory_related_name`` (See :issue:`58`) 521 522 523.. _v2.0.2: 524 5252.0.2 (2013-04-16) 526------------------ 527 528*New:* 529 530 - When :attr:`~factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE` is 531 empty, use ``Model.objects.create()`` instead of ``Model.objects.get_or_create``. 532 533 534.. _v2.0.1: 535 5362.0.1 (2013-04-16) 537------------------ 538 539*New:* 540 541 - Don't push ``defaults`` to ``get_or_create`` when 542 :attr:`~factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE` is not set. 543 544 545.. _v2.0.0: 546 5472.0.0 (2013-04-15) 548------------------ 549 550*New:* 551 552 - Allow overriding the base factory class for :func:`~factory.make_factory` and friends. 553 - Add support for Python3 (Thanks to `kmike <https://github.com/kmike>`_ and `nkryptic <https://github.com/nkryptic>`_) 554 - The default :attr:`~factory.Sequence.type` for :class:`~factory.Sequence` is now :obj:`int` 555 - Fields listed in :attr:`~factory.Factory.FACTORY_HIDDEN_ARGS` won't be passed to 556 the associated class' constructor 557 - Add support for ``get_or_create`` in :class:`~factory.django.DjangoModelFactory`, 558 through :attr:`~factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE`. 559 - Add support for :mod:`~factory.fuzzy` attribute definitions. 560 - The :class:`Sequence` counter can be overridden when calling a generating function 561 - Add :class:`~factory.Dict` and :class:`~factory.List` declarations (Closes :issue:`18`). 562 563*Removed:* 564 565 - Remove associated class discovery 566 - Remove :class:`~factory.InfiniteIterator` and :func:`~factory.infinite_iterator` 567 - Remove :class:`~factory.CircularSubFactory` 568 - Remove ``extract_prefix`` kwarg to post-generation hooks. 569 - Stop defaulting to Django's ``Foo.objects.create()`` when "creating" instances 570 - Remove STRATEGY_* 571 - Remove :meth:`~factory.Factory.set_building_function` / :meth:`~factory.Factory.set_creation_function` 572 573 574.. _v1.3.0: 575 5761.3.0 (2013-03-11) 577------------------ 578 579.. warning:: This version deprecates many magic or unexplicit features that will be 580 removed in v2.0.0. 581 582 Please read the :ref:`changelog-1-3-0-upgrading` section, then run your 583 tests with ``python -W default`` to see all remaining warnings. 584 585New 586""" 587 588- **Global:** 589 - Rewrite the whole documentation 590 - Provide a dedicated :class:`~factory.mogo.MogoFactory` subclass of :class:`~factory.Factory` 591 592- **The Factory class:** 593 - Better creation/building customization hooks at :meth:`factory.Factory._build` and :meth:`factory.Factory.create` 594 - Add support for passing non-kwarg parameters to a :class:`~factory.Factory` 595 wrapped class through :attr:`~factory.Factory.FACTORY_ARG_PARAMETERS`. 596 - Keep the :attr:`~factory.Factory.FACTORY_FOR` attribute in :class:`~factory.Factory` classes 597 598- **Declarations:** 599 - Allow :class:`~factory.SubFactory` to solve circular dependencies between factories 600 - Enhance :class:`~factory.SelfAttribute` to handle "container" attribute fetching 601 - Add a :attr:`~factory.Iterator.getter` to :class:`~factory.Iterator` 602 declarations 603 - A :class:`~factory.Iterator` may be prevented from cycling by setting 604 its :attr:`~factory.Iterator.cycle` argument to ``False`` 605 - Allow overriding default arguments in a :class:`~factory.PostGenerationMethodCall` 606 when generating an instance of the factory 607 - An object created by a :class:`~factory.django.DjangoModelFactory` will be saved 608 again after :class:`~factory.PostGeneration` hooks execution 609 610 611Pending deprecation 612""""""""""""""""""" 613 614The following features have been deprecated and will be removed in an upcoming release. 615 616- **Declarations:** 617 - :class:`~factory.InfiniteIterator` is deprecated in favor of :class:`~factory.Iterator` 618 - :class:`~factory.CircularSubFactory` is deprecated in favor of :class:`~factory.SubFactory` 619 - The ``extract_prefix`` argument to :meth:`~factory.post_generation` is now deprecated 620 621- **Factory:** 622 - Usage of :meth:`~factory.Factory.set_creation_function` and :meth:`~factory.Factory.set_building_function` 623 are now deprecated 624 - Implicit associated class discovery is no longer supported, you must set the :attr:`~factory.Factory.FACTORY_FOR` 625 attribute on all :class:`~factory.Factory` subclasses 626 627 628.. _changelog-1-3-0-upgrading: 629 630Upgrading 631""""""""" 632 633This version deprecates a few magic or undocumented features. 634All warnings will turn into errors starting from v2.0.0. 635 636In order to upgrade client code, apply the following rules: 637 638- Add a ``FACTORY_FOR`` attribute pointing to the target class to each 639 :class:`~factory.Factory`, instead of relying on automatic associated class 640 discovery 641- When using factory_boy for Django models, have each factory inherit from 642 :class:`~factory.django.DjangoModelFactory` 643- Replace ``factory.CircularSubFactory('some.module', 'Symbol')`` with 644 ``factory.SubFactory('some.module.Symbol')`` 645- Replace ``factory.InfiniteIterator(iterable)`` with ``factory.Iterator(iterable)`` 646- Replace ``@factory.post_generation()`` with ``@factory.post_generation`` 647- Replace ``factory.set_building_function(SomeFactory, building_function)`` with 648 an override of the :meth:`~factory.Factory._build` method of ``SomeFactory`` 649- Replace ``factory.set_creation_function(SomeFactory, creation_function)`` with 650 an override of the :meth:`~factory.Factory._create` method of ``SomeFactory`` 651 652 653 654.. _v1.2.0: 655 6561.2.0 (2012-09-08) 657------------------ 658 659*New:* 660 661 - Add :class:`~factory.CircularSubFactory` to solve circular dependencies between factories 662 663 664.. _v1.1.5: 665 6661.1.5 (2012-07-09) 667------------------ 668 669*Bug fix:* 670 671 - Fix :class:`~factory.PostGenerationDeclaration` and derived classes. 672 673 674.. _v1.1.4: 675 6761.1.4 (2012-06-19) 677------------------ 678 679*New:* 680 681 - Add :meth:`~factory.use_strategy` decorator to override a 682 :class:`~factory.Factory`'s default strategy 683 - Improve test running (tox, python2.6/2.7) 684 - Introduce :class:`~factory.PostGeneration` and 685 :class:`~factory.RelatedFactory` 686 687 688.. _v1.1.3: 689 6901.1.3 (2012-03-09) 691------------------ 692 693*Bug fix:* 694 695 - Fix packaging rules 696 697 698.. _v1.1.2: 699 7001.1.2 (2012-02-25) 701------------------ 702 703*New:* 704 705 - Add :class:`~factory.Iterator` and :class:`~factory.InfiniteIterator` for :class:`~factory.Factory` attribute declarations. 706 - Provide :func:`~factory.Factory.generate` and :func:`~factory.Factory.simple_generate`, that allow specifying the instantiation strategy directly. 707 Also provides :func:`~factory.Factory.generate_batch` and :func:`~factory.Factory.simple_generate_batch`. 708 709 710.. _v1.1.1: 711 7121.1.1 (2012-02-24) 713------------------ 714 715*New:* 716 717 - Add :func:`~factory.Factory.build_batch`, :func:`~factory.Factory.create_batch` and :func:`~factory.Factory.stub_batch`, to instantiate factories in batch 718 719 720.. _v1.1.0: 721 7221.1.0 (2012-02-24) 723------------------ 724 725*New:* 726 727 - Improve the :class:`~factory.SelfAttribute` syntax to fetch sub-attributes using the ``foo.bar`` syntax; 728 - Add :class:`~factory.ContainerAttribute` to fetch attributes from the container of a :class:`~factory.SubFactory`. 729 - Provide the :func:`~factory.make_factory` helper: ``MyClassFactory = make_factory(MyClass, x=3, y=4)`` 730 - Add :func:`~factory.build`, :func:`~factory.create`, :func:`~factory.stub` helpers 731 732*Bug fix:* 733 734 - Allow ``classmethod``/``staticmethod`` on factories 735 736*Deprecation:* 737 738 - Auto-discovery of :attr:`~factory.Factory.FACTORY_FOR` based on class name is now deprecated 739 740 741.. _v1.0.4: 742 7431.0.4 (2011-12-21) 744------------------ 745 746*New:* 747 748 - Improve the algorithm for populating a :class:`~factory.Factory` attributes dict 749 - Add ``python setup.py test`` command to run the test suite 750 - Allow custom build functions 751 - Introduce :data:`~factory.MOGO_BUILD` build function 752 - Add support for inheriting from multiple :class:`~factory.Factory` 753 - Base :class:`~factory.Factory` classes can now be declared :attr:`abstract <factory.Factory.ABSTRACT_FACTORY>`. 754 - Provide :class:`~factory.django.DjangoModelFactory`, whose :class:`~factory.Sequence` counter starts at the next free database id 755 - Introduce :class:`~factory.SelfAttribute`, a shortcut for ``factory.LazyAttribute(lambda o: o.foo.bar.baz``. 756 757*Bug fix:* 758 759 - Handle nested :class:`~factory.SubFactory` 760 - Share sequence counter between parent and subclasses 761 - Fix :class:`~factory.SubFactory` / :class:`~factory.Sequence` interference 762 763 764.. _v1.0.2: 765 7661.0.2 (2011-05-16) 767------------------ 768 769*New:* 770 771 - Introduce :class:`~factory.SubFactory` 772 773 774.. _v1.0.1: 775 7761.0.1 (2011-05-13) 777------------------ 778 779*New:* 780 781 - Allow :class:`~factory.Factory` inheritance 782 - Improve handling of custom build/create functions 783 784*Bug fix:* 785 786 - Fix concurrency between :class:`~factory.LazyAttribute` and :class:`~factory.Sequence` 787 788 789.. _v1.0.0: 790 7911.0.0 (2010-08-22) 792------------------ 793 794*New:* 795 796 - First version of factory_boy 797 798 799Credits 800------- 801 802See :doc:`credits`. 803 804.. vim:et:ts=4:sw=4:tw=119:ft=rst: 805