[test] add new fixture to generate random strings of given length
This commit is contained in:
parent
86ccdd58ee
commit
051f0b964e
1 changed files with 13 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.test import Client
|
from django.test import Client
|
||||||
|
|
||||||
|
@ -10,3 +14,12 @@ def enable_db_access_for_all_tests(db):
|
||||||
@pytest.fixture(scope="session", name="session")
|
@pytest.fixture(scope="session", name="session")
|
||||||
def fixture_longlived_client() -> Client:
|
def fixture_longlived_client() -> Client:
|
||||||
return 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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue