-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
30 lines (24 loc) · 844 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
from faker import Faker
from datetime import datetime
faker = Faker()
DATA_GENERATORS = {
"first_name": lambda: faker.unique.first_name(),
"last_name": lambda: faker.unique.last_name(),
"middle_name": lambda: faker.name_nonbinary(),
"id": lambda: faker.unique.bothify(text="??????????"),
"date": lambda: datetime.now().strftime("%Y-%d-%m"),
"nationality": lambda: "Afghan",
"marital_status": lambda: "Single",
"gender": lambda: "Female",
}
@pytest.fixture(scope="function")
def data_generator():
"""
Universal factory to generate different types of test data.
"""
def _generate(data_type: str) -> str:
if data_type not in DATA_GENERATORS:
raise ValueError(f"Unknown data type: {data_type}")
return DATA_GENERATORS[data_type]()
return _generate