summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/changelog.rst9
-rw-r--r--docs/fuzzy.rst10
-rw-r--r--docs/recipes.rst22
3 files changed, 39 insertions, 2 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst
index d18f8e2..0bf0eb3 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -2,6 +2,15 @@ ChangeLog
=========
+.. _v2.4.0:
+
+2.4.0 (master)
+--------------
+
+*New:*
+
+ - Add support for :attr:`factory.fuzzy.FuzzyInteger.step`, thanks to `ilya-pirogov <https://github.com/ilya-pirogov>`_ (:issue:`120`)
+
.. _v2.3.1:
2.3.1 (maint)
diff --git a/docs/fuzzy.rst b/docs/fuzzy.rst
index b94dfa5..2fe60b8 100644
--- a/docs/fuzzy.rst
+++ b/docs/fuzzy.rst
@@ -73,7 +73,7 @@ FuzzyChoice
FuzzyInteger
------------
-.. class:: FuzzyInteger(low[, high])
+.. class:: FuzzyInteger(low[, high[, step]])
The :class:`FuzzyInteger` fuzzer generates random integers within a given
inclusive range.
@@ -82,7 +82,7 @@ FuzzyInteger
.. code-block:: pycon
- >>> FuzzyInteger(0, 42)
+ >>> fi = FuzzyInteger(0, 42)
>>> fi.low, fi.high
0, 42
@@ -98,6 +98,12 @@ FuzzyInteger
int, the inclusive higher bound of generated integers
+ .. attribute:: step
+
+ int, the step between values in the range; for instance, a ``FuzzyInteger(0, 42, step=3)``
+ might only yield values from ``[0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]``.
+
+
FuzzyDecimal
------------
diff --git a/docs/recipes.rst b/docs/recipes.rst
index c1f3700..9e07413 100644
--- a/docs/recipes.rst
+++ b/docs/recipes.rst
@@ -291,3 +291,25 @@ Here, we want:
name = "ACME, Inc."
country = factory.SubFactory(CountryFactory)
owner = factory.SubFactory(UserFactory, country=factory.SelfAttribute('..country'))
+
+
+Custom manager methods
+----------------------
+
+Sometimes you need a factory to call a specific manager method other then the
+default :meth:`Model.objects.create() <django.db.models.query.QuerySet.create>` method:
+
+.. code-block:: python
+
+ class UserFactory(factory.DjangoModelFactory):
+ FACTORY_FOR = UserenaSignup
+ username = "l7d8s"
+ email = "my_name@example.com"
+ password = "my_password"
+
+ @classmethod
+ def _create(cls, target_class, *args, **kwargs):
+ """Override the default ``_create`` with our custom call."""
+ manager = cls._get_manager(target_class)
+ # The default would use ``manager.create(*args, **kwargs)``
+ return manager.create_user(*args, **kwargs)