Commit 41364411 authored by Laurent Bachelier's avatar Laurent Bachelier

Allow tests to run on machines with bad entropy

parent 88152e6e
......@@ -5,14 +5,17 @@ from binascii import hexlify
__all__ = ['random', 'armored_random',
'new_user_key', 'new_salt', 'new_secret']
SECURE = os.getenv('ASS2M_FAST_TEST') != '1'
def random(n):
"""
Get random bytes.
Try to use the best random source or fall back to os.urandom.
"""
source = "/dev/random" if SECURE else "/dev/urandom"
try:
with open("/dev/random", "r") as randomfd:
with open(source, "r") as randomfd:
bs = b""
while n > len(bs):
bs += randomfd.read(n - len(bs))
......
#!/bin/sh -xe
if [ "$1" == '--slow' ]; then
ASS2M_FAST_TEST=0
shift
else
ASS2M_FAST_TEST=1
fi
export ASS2M_FAST_TEST
if [ "$1" != "" ]; then
nosetests -sv $(dirname $0)/../tests/$1_test.py
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment