I do something like this (using Matlab not Python), but I don't look for particular featueres in the student answer. I use a template grader (see the CodeRunner documentation) which runs both the student answer and the 'model answer' and compares the outputs from each of these for marking. My template grader adds code before the answer code (student, model) to set the prng state.
That is a short description that covers a lot of complexity! I spent a bit of time building up to it. I do not think it would have been worth it just for the sake of being able to ask 'generate a random number' questions, but our course (which is more 'coding for engineers' than 'programming') had a lot of particular needs that meant that I had to write a template grader that ran both student answer and model answer anyway.
You may be able to get at something close to what you want to assess without the full CodeRunner setup in this case. Overall I feel very strongly that when we want to assess students' ability to write code the best way to do that is to get them to write code, but sometimes it takes a lot of additional work to assess something that is not in itself an absolutely core skill. I use the fact that I can mix a few non-CodeRunner questions (using other Moodle question types) into a Moodle quiz to give me a bit of flexibility.
It might be worth considering whether you could use (say) a multiple choice question (like "which of the following could you use to ...") as a stopgap to cover random number generation while you build up to writing template graders. You could mix that in with CodeRunner questions that tackle things that the existing built-in question types assess well.
One final comment on assessing by looking for particular things in the student code. That in itself can get quite complicated (you have to consider the different ways they could achieve the same end, use of variables or hard-coded inputs, whitespace...) and in some ways it may go away from the idea of students writing code that is run to see if it actually does what is required.
This is all based on my own experience and I may be missing something really important or useful.