Skip to content

Commit

Permalink
Re-format @autodata and @fakedata comments
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhelle committed Oct 19, 2024
1 parent f97270e commit b6e77f5
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions src/autofaker/decorators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Provides anonymous object creation functions to help minimize the setup/arrange phase when writing unit tests
Provides anonymous object creation functions to help minimize
the setup/arrange phase when writing unit tests
"""

import inspect
Expand All @@ -11,7 +12,8 @@

def autodata(*types: object, use_fake_data: bool = False):
"""
Creates anonymous variable of the requested types and pass them as arguments to a unit test function
Creates anonymous variable of the requested types
and pass them as arguments to a unit test function
Example:
Expand All @@ -26,8 +28,14 @@ def test_create_str_argument_using_decorator(self, text, number, decimal, boolea
self.assertIsNotNone(text)
:param use_fake_data: bool - Set this to True to use Faker to generate data, otherwise False to generate anonymous data
:param type types: tuple - The types to generate data. This is optional and will use the arguments from the function being decorated if not specified
:param use_fake_data: bool
Set this to True to use Faker to generate data,
otherwise False to generate anonymous data
:param type types: tuple
The types to generate data.
This is optional and will use the arguments
from the function being decorated if not specified
"""

def decorator(function):
Expand Down Expand Up @@ -56,7 +64,8 @@ def wrapper(*args):

def fakedata(*types: object):
"""
Creates fake values for the variables of the requested types and pass them as arguments to a unit test function
Creates fake values for the variables of the requested types
and pass them as arguments to a unit test function
Example:
Expand All @@ -71,7 +80,10 @@ def test_create_fake_arguments(self, text: str, number: int, decimal: float, boo
self.assertIsNotNone(text)
:param types: object - The types to generate data. This is optional and will use the arguments from the function being decorated if not specified
:param types: object
The types to generate data.
This is optional and will use the arguments from the function
being decorated if not specified
"""

def decorator(function):
Expand All @@ -98,11 +110,19 @@ def wrapper(*args):

def autopandas(t: object, rows: int = 3, use_fake_data: bool = False):
"""
Create a Pandas DataFrame containing anonymous data with the specified number of rows (default 3)
Create a Pandas DataFrame containing anonymous data
with the specified number of rows (default 3)
:param type t: object
The class that represents the DataFrame.
This can be a plain old class or a @dataclass
:param type t: object - The class that represents the DataFrame. This can be a plain old class or a @dataclass
:param type rows: int - The number of rows to generate for the DataFrame (default 3)
:param use_fake_data: bool - Set this to True to use Faker to generate data, otherwise False to generate anonymous data
:param type rows: int
The number of rows to generate for the DataFrame (default 3)
:param use_fake_data: bool
Set this to True to use Faker to generate data,
otherwise False to generate anonymous data
"""

def decorator(function):
Expand All @@ -121,10 +141,15 @@ def wrapper(*args):

def fakepandas(t, rows: int = 3):
"""
Create a Pandas DataFrame containing fake data with the specified number of rows (default 3)
Create a Pandas DataFrame containing fake data with
the specified number of rows (default 3)
:param type t: object
The class that represents the DataFrame.
This can be a plain old class or a @dataclass
:param type t: object - The class that represents the DataFrame. This can be a plain old class or a @dataclass
:param type rows: int - The number of rows to generate for the DataFrame (default 3)
:param type rows: int
The number of rows to generate for the DataFrame (default 3)
"""
return autopandas(t, rows, use_fake_data=True)

Expand Down

0 comments on commit b6e77f5

Please sign in to comment.