mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
Use more reproducible "random" numbers.
This commit is contained in:
parent
b01c5c7454
commit
a482f216a1
@ -18,7 +18,7 @@ if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
# fmt: on
|
||||
|
||||
from random import randrange
|
||||
from random import Random
|
||||
|
||||
from testtools import skipIf
|
||||
|
||||
@ -31,10 +31,15 @@ from .test_system import SystemTestMixin
|
||||
from .common import AsyncTestCase
|
||||
|
||||
|
||||
# Use random generator with known seed, so results are reproducible if tests
|
||||
# are run in the same order.
|
||||
_RANDOM = Random(0)
|
||||
|
||||
|
||||
def _randbytes(length):
|
||||
# type: (int) -> bytes
|
||||
"""Return random bytes string of given length."""
|
||||
return b"".join([bchr(randrange(0, 256)) for _ in range(length)])
|
||||
return b"".join([bchr(_RANDOM.randrange(0, 256)) for _ in range(length)])
|
||||
|
||||
|
||||
def new_storage_index():
|
||||
|
Loading…
Reference in New Issue
Block a user