Fix issue with generate random string

Signed-off-by: Aleksei Chetaev <alex.chetaev@gmail.com>
This commit is contained in:
Aleksei Chetaev 2023-03-06 17:39:03 +01:00
parent 71b35d45c3
commit 8ed26cef7d

View file

@ -4,6 +4,7 @@ import string
ONLY_ASCII_LETTERS = string.ascii_letters ONLY_ASCII_LETTERS = string.ascii_letters
DIGITS_AND_ASCII_LETTERS = string.ascii_letters + string.digits DIGITS_AND_ASCII_LETTERS = string.ascii_letters + string.digits
NON_DIGITS_AND_LETTERS = string.punctuation
def random_string(length: int = 5, source: str = ONLY_ASCII_LETTERS): def random_string(length: int = 5, source: str = ONLY_ASCII_LETTERS):
@ -17,7 +18,7 @@ def random_string(length: int = 5, source: str = ONLY_ASCII_LETTERS):
(str): random string with len == length (str): random string with len == length
""" """
return "".join(random.choice(string.ascii_letters) for i in range(length)) return "".join(random.choice(source) for i in range(length))
def is_str_match_pattern(error: Exception, status_pattern: str) -> bool: def is_str_match_pattern(error: Exception, status_pattern: str) -> bool: