Skip to content

Commit

Permalink
Add documentation on how to use unqiue with faker.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurHamon2 committed Nov 18, 2020
1 parent 6f64f80 commit f77d357
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,22 @@ Faker
date_end=datetime.date(2020, 5, 31),
)
Since Faker 4.9.0 version (see `Faker documentation <https://faker.readthedocs.io/en/latest/>`_),
on every providers, you can specify whether to return an unique value or not:

.. code-block:: python
class UserFactory(fatory.Factory):
class Meta:
model = User
arrival = factory.Faker(
'date_between_dates',
date_start=datetime.date(2020, 1, 1),
date_end=datetime.date(2020, 5, 31),
unique=True # The generated date is guaranteed to be unique inside the test execution.
)
As with :class:`~factory.SubFactory`, the parameters can be any valid declaration.
This does not apply to the provider name or the locale.

Expand Down

0 comments on commit f77d357

Please sign in to comment.