factory_boy icon indicating copy to clipboard operation
factory_boy copied to clipboard

Clarify deprecated parts in `factory.fuzzy`

Open rbarrois opened this issue 5 years ago • 2 comments

The problem

Some of the features included in factory.fuzzy are now a duplicate of faker-provided items. But some don't have a satisfactory equivalent.

Proposed solution

  • Describe what is, and isn't, deprecated;
  • Clarify the differences

Extra notes

For instance:

  • factory.fuzzy.FuzzyChoice is guaranteed to be lazy, whereas factory.Faker('random_choice', elements=...) isn't — the latter might evaluate a queryset at import time;
  • factory.fuzzy.FuzzyDateTime is explicitly timezone-aware, whereas Faker defaults to naive datetime;
  • The current API for factory.Faker makes for less readable/IDE-compatible code compared to factory.Fuzzy.

rbarrois avatar Jul 06 '20 20:07 rbarrois

Moving forward:

  • Generate equivalents based on Faker for those that have them and deprecate them: this would educate and flag for future removal
  • Provide alternatives to Faker for things we'd like to behave differently or is non existent
  • Finally, remove or shrink fuzzy

Sorry, my proposal (jotting this down before going into a meeting).

melvyn-apryl avatar Apr 26 '21 13:04 melvyn-apryl

Faker is harder to use in factory.lazy_attribute, missing a fuzz() that can just be called, especially for types like dates that depend on each other to form a valid period, this is non obvious (still figuring that out).

melvyn-apryl avatar May 07 '21 13:05 melvyn-apryl