Not possible to seed uuid4
See original GitHub issueIt is not possible to seed the uuid4 property.
>>> f1 = Faker()
>>> f1.seed(4321)
>>> print(f1.uuid4())
4a6d35db-b61b-49ed-a225-e16bc164f7cc
>>> f2 = Faker()
>>> f2.seed(4321)
>>> print(f2.uuid4())
b5f05be8-2f57-4a52-9b6f-5bcd03125278
The solution is pretty much given in: http://stackoverflow.com/questions/41186818/how-to-generate-a-random-uuid-which-is-reproducible-with-a-seed-in-python
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
How to generate a random UUID which is reproducible (with a ...
I would like to be able to generate the same random UUID every time I run a script - that is, I'd like...
Read more >Consistent Random UUIDs in Python - Nathaniel Knight
This is a little trickier than I thought it would be, but it's certainly possible. My first instinct was to set the random...
Read more >uuid — UUID objects according to RFC 4122 ... - Python Docs
uuid4 () creates a random UUID. Depending on support from the underlying platform, uuid1() may or may not return a “safe” UUID. A...
Read more >A Complete Guide to UUID Versions (v1, v4, v5) - With Examples
UUIDs address the problem of generating a unique ID - either randomly, or using some data as a seed. However, ensuring uniqueness is...
Read more >Python UUID Module to Generate Universally Unique Identifiers
Generate a reproducible UUID using a seed value; Extract UUID attributes ... Also, read Working with random data in Python (Complete Guide).
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
The tests which were added in #1050 (and closed out this ticket) are still in the repo at
https://github.com/joke2k/faker/blob/594d34414b137071f59b9fc75442206244c234cd/tests/providers/test_misc.py#L68-L75
I don’t use Faker anymore, but after looking at the code it looks like it should now work with seeding and properly return v4 UUIDs.
That is not correct. And 15/16 times it will produce a UUID that is not version 4.
There are a total of 8 bits that must be set manually in order for it to be properly detected as a UUIDv4.