[test] add new fixture to generate random strings of given length

This commit is contained in:
bronsen 2025-03-15 22:25:13 +01:00
parent 86ccdd58ee
commit 051f0b964e

View file

@ -1,3 +1,7 @@
import random
import string
from typing import Callable
import pytest
from django.test import Client
@ -10,3 +14,12 @@ def enable_db_access_for_all_tests(db):
@pytest.fixture(scope="session", name="session")
def fixture_longlived_client() -> Client:
return Client()
@pytest.fixture(name="random_name")
def fixture_random_name_generator() -> Callable[[int], str]:
def name_generator(length: int = 7) -> str:
name = "".join(random.choices(string.ascii_letters, k=length))
return name
return name_generator