How to cast Faker data with Factory Boy ?

124 views
Skip to first unread message

Olivier

unread,
Nov 19, 2019, 8:05:42 AM11/19/19
to Django users
Hello,

I'm discovering Factory Boy with a Django 2.2 project.
Factory Boy now ships with Faker which is very convenient to generate test data.

Faker generates string of all kinds to match phone numbers, postal or IP addresses.

How do you use Faker/Factory Boy to cast generated data into a specific type for which a constructor accepting a string  as its unique argument, exists ?
For instance, Faker generates IP addresses which are simple strings.
I would prefer to convert this string into a Python ipaddress.IPv4Address().

How can I do that ?
For reference, I opened the issue [1] on Faker's Github site.



Best regards
Reply all
Reply to author
Forward
0 new messages