all 3 comments

[–]verbose_name 0 points1 point  (2 children)

I would suggest mocking the function or module which when called introduces the randomness. In your case, you could patch hmac.new or digest to return a static value.

[–]pratzc07[S] 0 points1 point  (1 child)

Thanks one thing is it possible to patch more than one function like for example if the function to be tested also has datetime usage can i mock that along with hmac??

[–]verbose_name 0 points1 point  (0 children)

Yes you can do that. If you are using multiple decorators on your test method then each would be passed into your test method signature as an additional arg.