diff --git a/moulinette/utils/text.py b/moulinette/utils/text.py index 2da101a5..edaa4d24 100644 --- a/moulinette/utils/text.py +++ b/moulinette/utils/text.py @@ -65,6 +65,6 @@ def prependlines(text, prepend): # Randomize ------------------------------------------------------------ -def random_ascii(length=20): +def random_ascii(length=40): """Return a random ascii string""" - return binascii.hexlify(os.urandom(length)).decode("ascii") + return binascii.hexlify(os.urandom(length)).decode("ascii")[:length] diff --git a/test/test_text.py b/test/test_text.py index 1bf1f896..4c31f292 100644 --- a/test/test_text.py +++ b/test/test_text.py @@ -20,3 +20,4 @@ def test_prependlines(): def test_random_ascii(): assert isinstance(random_ascii(length=2), str) + assert len(random_ascii(length=10)) == 10