Factory-boy

Latest version: v3.3.1

Safety actively analyzes 682404 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 6 of 8

2.1.1

------------------

*Bug fix:*

- Properly retrieve the ``color`` keyword argument passed to :class:`~factory.django.ImageField`

2.1.0

------------------

*New:*

- Add :class:`~factory.fuzzy.FuzzyDate` thanks to `saulshanabrook <https://github.com/saulshanabrook>`_
- Add :class:`~factory.fuzzy.FuzzyDateTime` and :class:`~factory.fuzzy.FuzzyNaiveDateTime`.
- Add a ``factory_parent`` attribute to the
``factory.builder.Resolver`` passed to :class:`~factory.LazyAttribute`, in order to access
fields defined in wrapping factories.
- Move :class:`~factory.django.DjangoModelFactory` and :class:`~factory.mogo.MogoFactory`
to their own modules (:mod:`factory.django` and :mod:`factory.mogo`)
- Add the :meth:`~factory.Factory.reset_sequence` classmethod to :class:`~factory.Factory`
to ease resetting the sequence counter for a given factory.
- Add debug messages to ``factory`` logger.
- Add a :meth:`~factory.Iterator.reset` method to :class:`~factory.Iterator` (:issue:`63`)
- Add support for the SQLAlchemy ORM through :class:`~factory.alchemy.SQLAlchemyModelFactory`
(:pr:`64`, thanks to `Romain Commandé <https://github.com/rcommande>`_)
- Add :class:`factory.django.FileField` and :class:`factory.django.ImageField` hooks for
related Django model fields (:issue:`52`)

*Bug fix*

- Properly handle non-integer primary keys in :class:`~factory.django.DjangoModelFactory` (:issue:`57`).
- Disable :class:`~factory.RelatedFactory` generation when a specific value was
passed (:issue:`62`, thanks to `Gabe Koscky <https://github.com/dhekke>`_)

*Deprecation:*

- Rename :class:`~factory.RelatedFactory`'s ``name`` argument to ``factory_related_name`` (See :issue:`58`)

2.0.2

------------------

*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

------------------

*New:*

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

2.0.0

------------------

*New:*

- Allow overriding the base factory class for :func:`~factory.make_factory` and friends.
- Add support for Python3 (Thanks to `kmike <https://github.com/kmike>`_ and `nkryptic <https://github.com/nkryptic>`_)
- The default type for :class:`~factory.Sequence` is now :obj:`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 :class:`~factory.django.DjangoModelFactory`,
through ``factory.django.DjangoModelFactory.FACTORY_DJANGO_GET_OR_CREATE``.
- Add support for :mod:`~factory.fuzzy` attribute definitions.
- The :class:`Sequence` counter can be overridden when calling a generating function
- Add :class:`~factory.Dict` and :class:`~factory.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``

1.3.0

------------------

.. warning:: This version deprecates many magic or unexplicit features that will be
removed in v2.0.0.

Please read the :ref:`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 :class:`~factory.mogo.MogoFactory` subclass of :class:`~factory.Factory`

- **The Factory class:**
- Better creation/building customization hooks at :meth:`factory.Factory._build` and :meth:`factory.Factory.create`
- Add support for passing non-kwarg parameters to a :class:`~factory.Factory`
wrapped class through ``FACTORY_ARG_PARAMETERS``.
- Keep the ``FACTORY_FOR`` attribute in :class:`~factory.Factory` classes

- **Declarations:**
- Allow :class:`~factory.SubFactory` to solve circular dependencies between factories
- Enhance :class:`~factory.SelfAttribute` to handle "container" attribute fetching
- Add a :attr:`~factory.Iterator.getter` to :class:`~factory.Iterator`
declarations
- A :class:`~factory.Iterator` may be prevented from cycling by setting
its :attr:`~factory.Iterator.cycle` argument to ``False``
- Allow overriding default arguments in a :class:`~factory.PostGenerationMethodCall`
when generating an instance of the factory
- An object created by a :class:`~factory.django.DjangoModelFactory` will be saved
again after :class:`~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 :class:`~factory.Iterator`
- ``factory.CircularSubFactory`` is deprecated in favor of :class:`~factory.SubFactory`
- The ``extract_prefix`` argument to :meth:`~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_FOR``
attribute on all :class:`~factory.Factory` subclasses


.. _changelog-1-3-0-upgrading:

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
:class:`~factory.Factory`, instead of relying on automatic associated class
discovery
- When using factory_boy for Django models, have each factory inherit from
:class:`~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 :meth:`~factory.Factory._build` method of ``SomeFactory``
- Replace ``factory.set_creation_function(SomeFactory, creation_function)`` with
an override of the :meth:`~factory.Factory._create` method of ``SomeFactory``

Page 6 of 8

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.