Global seeding does not work as expected
See original GitHub issueConsider the following code:
import unittest
import random
from mimesis import Food
class Test(unittest.TestCase):
def test_food(self):
f = Food("en")
print(">>", f.dish())
if __name__ == "__main__":
random.seed("123")
unittest.main()
I would expect that for consecutive runs the same dish is printed but it’s not:
>> Macaroni and Cheese
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
Press ENTER or type command to continue
>> Ploye
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
The question now is whether that is expected behavior? I know there is a specific seed for each Provider.
Because I find it a bit annoying, requiring me to jump a few more hoops to get this under test.
>> python --version
Python 3.5.3
>> pip freeze|grep mime
mimesis==1.0.4
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Seeding the generator in Python's "faker" module not working ...
This is fine, but it means that the second faker is pulling a global random number, so it is the same as if...
Read more >Availability Group Direct Seeding: How to fix a database that ...
This post covers two scenarios. You either created a database, and the sync failed for some reason, or a database stopped syncing.
Read more >Data Seeding - Understanding Scenario Setup - Planful
If no account mapping, Actual data is seeded. Calculated Lines without Account Mapping - Formula and result seed from Seed Data From scenario ......
Read more >Depressing Study Shows a Big Issue With Using Cloud ...
The idea of seeding clouds with an injection of light-reflecting particles to reflect sunlight back into space – thereby 'cooling' the planet – ......
Read more >Data Seeding - EF Core - Microsoft Learn
Data seeding is the process of populating a database with an initial set of data. There are several ways this can be accomplished...
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 Free
Top 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

@duckyou Thanks for effort you put into answering my question. Now I feel a bit ashamed noticing that my initial example is a bit misleading. I am using your awesome lib to produce names for things and I have an integration test that verify things get names. What I wanted to do is hardwire the test output. Something like this:
HTH. What I am currently doing is seeding via
os.envsomewhere inservicewhich is ok for now. Thanks again for answering my questions.@duckyou Can you advise anything, please?