https://github.com/headsrooms/fistro
A fixture generator based on type annotations.
https://github.com/headsrooms/fistro
annotations dataclasses fixture-data fixture-generator fixture-test fixtures python test testing-library testing-tools
Last synced: 5 months ago
JSON representation
A fixture generator based on type annotations.
- Host: GitHub
- URL: https://github.com/headsrooms/fistro
- Owner: headsrooms
- License: mit
- Created: 2018-07-26T09:25:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T19:59:03.000Z (over 4 years ago)
- Last Synced: 2025-09-12T03:05:05.606Z (9 months ago)
- Topics: annotations, dataclasses, fixture-data, fixture-generator, fixture-test, fixtures, python, test, testing-library, testing-tools
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Fistro
======

[](https://codecov.io/gh/headsrooms/fistro)
A fixture generator based on type annotations.
Examples
--------
```python
from dataclasses import dataclass
from datetime import datetime, date
from typing import List
from fistro.fistro import generate
@dataclass
class Employee:
id: int
birthday: date
last_access: datetime
password: str
number_plates: List[int]
name: str = 'Carlos Sánchez'
employee = generate(Employee)()
print(employee)
```
It will show something like this:
```python
Employee(id=5809893100, birthday=datetime.date(559, 3, 6), last_access=datetime.datetime(1053, 8, 29, 19, 11, 14), password="iFZ>?)V0'", number_plates=[85863115, 3528889142, 2818728907, 6043092538, 4985672707], name='Carlos Sánchez')
```
`generate` function can be called with `to_json` or `to_dict`
boolean pararameters to return json or dict
representation respectively:
```python
class AreaOfCompany(BaseModel):
enable: bool
riskOwner: str
description: str
name: str
code: str
print(fistro.generate(AreaOfCompany, as_dict=True))
```
>>> {'enable': True, 'riskOwner': 'LqPqS\x0c{kZ', 'description': 'k1917GvOV', 'name': '`;ORxzQ7i', 'code': 'w2 |P\rEps'}
```python
print(fistro.generate(AreaOfCompany, as_json=True))
```
>>> {"enable": true, "riskOwner": "h@Ij34u?H", "description": ",R,G%0