Exemplo n.º 1
0
 def test_reseed_if_needed(self):
     # we have to set a seed in order to be able to get state
     random.seed(codecs.encode("abcdefg", "utf-8"))
     state = random.getstate()
     _reseed_if_needed(using_sysrandom=True, secret_key=None)
     # did NOT reseed
     assert state == random.getstate()
     # monkeypatch
     saved = bokeh.util.session_id.random
     try:
         bokeh.util.session_id.random = random
         _reseed_if_needed(using_sysrandom=False, secret_key="abc")
         # DID reseed
         assert state != random.getstate()
     finally:
         bokeh.util.session_id.random = saved
Exemplo n.º 2
0
 def test_reseed_if_needed(self):
     # we have to set a seed in order to be able to get state
     random.seed(codecs.encode("abcdefg", "utf-8"))
     state = random.getstate()
     _reseed_if_needed(using_sysrandom=True, secret_key=None)
     # did NOT reseed
     assert state == random.getstate()
     # monkeypatch
     saved = bokeh.util.session_id.random
     try:
         bokeh.util.session_id.random = random
         _reseed_if_needed(using_sysrandom=False, secret_key="abc")
         # DID reseed
         assert state != random.getstate()
     finally:
         bokeh.util.session_id.random = saved