Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I don't understand why you would want to ensure that mocked_randint is called_with certain values. I understand wanting to mock randint to return predictable values, but isn't the concern just that it returns predictable values and not what values it is called with? It seems to me that checking the called values is unnecessarily tying the test to fine details of implementation. Also why do we care that the die returns the exact value of randint? Don't we really just care that it returns a value > 1 and less than equal to the max?
Say you mock the RNG to be predictable. Well what do you then test? The question asks "Would the following be valid/useful unit tests?" Mocking it to return 0-5 is not a test but rather test setup. How would you "unit test accordingly"? I am failing to understand how it "does catch bugs". I am having a hard time understanding what I need to 'unit' test.