use {word1}_{word2}{digits} as random alias address instead of {word1}{word2}{digits} (#1673)

This commit is contained in:
Son Nguyen Kim 2023-04-04 08:46:29 +02:00 committed by GitHub
parent 1f9d784382
commit 03e5083d97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -32,8 +32,8 @@ def random_words(words: int = 2, numbers: int = 0):
fields = [secrets.choice(_words) for i in range(words)]
if numbers > 0:
fields.append("".join([str(random.randint(0, 9)) for i in range(numbers)]))
return "".join(fields)
digits = "".join([str(random.randint(0, 9)) for i in range(numbers)])
return "_".join(fields) + digits
else:
return "_".join(fields)

View file

@ -13,7 +13,7 @@ def test_random_words():
assert s.count("_") == 1
assert len(s) > 3
s = random_words(2, 3)
assert s.count("_") == 0
assert s.count("_") == 1
assert s[-1] in (str(i) for i in range(10))