How to create Profile.username with faker?
See original GitHub issueI wanna create random value with faker
wrapper, however, I can’t get extract any value from it.
# not working
username = factory.Faker('profile')['username']
Has anyone done this before?
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
faker.providers.profile — Faker 15.3.4 documentation
This provider is a collection of functions to generate personal profiles and identities. ... Built with Sphinx using a theme provided by Read...
Read more >How to create fake user profiles using faker in Python
The attributes of the profile generated are as follows: username; name; sex; address; mail; birthdate. Method signature. simple_profile(sex ...
Read more >How to use userName function in faker - Javascript - Tabnine
const generateUser = () => { const createdAt = faker.date.past(2); const name = faker.name.findName(); return { id: uuid(), name, ...
Read more >Python Faker.user_name Examples
Python Faker.user_name - 30 examples found. These are the top rated real world Python examples of faker.Faker.user_name extracted from open source projects.
Read more >How to Create Fake Data with Faker | by Khuyen Tran
fake = Faker()fake.profile(). As we can see, most relevant information about a person is created with ease, even with mail, ssn, username, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s a bit hidden, but Faker has a
user_name
provider: http://faker.readthedocs.io/en/latest/providers/faker.providers.internet.html?highlight=user_name=> You can use
factory.Faker('user_name')
😉Well I have a not super great solution. It adds an extra call so maybe someone can clean it up:
Test
Output:
So the reason I went with a LazyAttribute is that if you don’t delay the call of a function in the factory then the items generated won’t be random. In my experience the first ‘username’ will be random but the rest will just repeat it. Given this behavior I decided to delay the function call until instantiation so that each instance gets a random name