Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
When running doctests, use the current_randstate()'s seed for Interfa…
Browse files Browse the repository at this point in the history
…ce.rand_seed()

This allows pexpect Interfaces that set some random seed to use a consistent,
predictable value for tests rather than being completely arbitrary.
  • Loading branch information
embray committed Dec 11, 2018
1 parent ad38820 commit d7c85cd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/sage/interfaces/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,16 @@ def rand_seed(self):
sage: s.rand_seed() # random
365260051L
"""
from sage.misc.randstate import randstate
return randstate().seed()&0x1FFFFFFF
import sage.doctest
if sage.doctest.DOCTEST_MODE:
# set the random seed through the current randstate
from sage.misc.randstate import current_randstate
seed = current_randstate().seed()
else:
from sage.misc.randstate import randstate
seed = randstate().seed()

return seed & 0x1FFFFFFF

def set_seed(self, seed=None):
"""
Expand Down

0 comments on commit d7c85cd

Please sign in to comment.