mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Fix random_ascii behavior : it was in fact returning a string with 2*length ...
This commit is contained in:
parent
b20b1af116
commit
4239f466f8
2 changed files with 3 additions and 2 deletions
|
@ -65,6 +65,6 @@ def prependlines(text, prepend):
|
||||||
# Randomize ------------------------------------------------------------
|
# Randomize ------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def random_ascii(length=20):
|
def random_ascii(length=40):
|
||||||
"""Return a random ascii string"""
|
"""Return a random ascii string"""
|
||||||
return binascii.hexlify(os.urandom(length)).decode("ascii")
|
return binascii.hexlify(os.urandom(length)).decode("ascii")[:length]
|
||||||
|
|
|
@ -20,3 +20,4 @@ def test_prependlines():
|
||||||
|
|
||||||
def test_random_ascii():
|
def test_random_ascii():
|
||||||
assert isinstance(random_ascii(length=2), str)
|
assert isinstance(random_ascii(length=2), str)
|
||||||
|
assert len(random_ascii(length=10)) == 10
|
||||||
|
|
Loading…
Reference in a new issue