diff --git a/pytest_abra/utils.py b/pytest_abra/utils.py index 828e6b9..b5bd3cf 100644 --- a/pytest_abra/utils.py +++ b/pytest_abra/utils.py @@ -1,3 +1,5 @@ +import random +import string from dataclasses import dataclass from datetime import datetime from pathlib import Path @@ -35,3 +37,12 @@ def rmtree(root_dir: Path): child.unlink() root_dir.rmdir() + + +def generate_random_string(length: int, punctuation=False) -> str: + """returns a random string of the given length""" + characters = string.ascii_letters + string.digits + if punctuation: + characters += string.punctuation + random_string = "".join(random.choice(characters) for _ in range(length)) + return random_string