Tuesday, November 19, 2019

How to cast Faker data with Factory Boy ?

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.


[1] https://github.com/joke2k/faker/issues/1057

Best regards

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b7e28909-660b-4115-8a81-a6a48e0d8330%40googlegroups.com.

No comments:

Post a Comment