diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afa95cc..f32f88d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,16 +31,6 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: Sleep for 60 seconds (Bash) - if: ${{ inputs.os != 'windows-latest' }} - run: sleep 60s - shell: bash - - - name: Sleep for 60 seconds (Powershell) - if: ${{ inputs.os == 'windows-latest' }} - run: Start-Sleep -s 60 - shell: powershell - - name: Install Requirements run: | pip install pytest diff --git a/setup.py b/setup.py index 75f4c64..9e5bb07 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,21 @@ import setuptools -with open('docs/pypi.md', 'r', encoding='utf-8') as fh: +with open("docs/pypi.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( - name='autofaker', - version='0.1.0', - url='https://github.com/christianhelle/autofaker', - license='MIT License', + name="autofaker", + version="0.1.0", + url="https://github.com/christianhelle/autofaker", + license="MIT License", license_files=["LICENSE"], - author='Christian Helle', - author_email='christian.helle@outlook.com', - description='Python library designed to minimize the setup/arrange phase of your unit tests', + author="Christian Helle", + author_email="christian.helle@outlook.com", + description="Python library designed to minimize the setup/arrange phase of your unit tests", long_description=long_description, - long_description_content_type='text/markdown', - package_dir={'': 'src'}, - packages=setuptools.find_packages(where='src'), - python_requires='>=3.7', - install_requires=['pandas', 'faker', 'typing_inspect'], + long_description_content_type="text/markdown", + package_dir={"": "src"}, + packages=setuptools.find_packages(where="src"), + python_requires=">=3.7", + install_requires=["pandas", "faker", "typing_inspect"], ) diff --git a/src/autofaker/attributes.py b/src/autofaker/attributes.py index 6383063..5524606 100644 --- a/src/autofaker/attributes.py +++ b/src/autofaker/attributes.py @@ -4,7 +4,8 @@ def __init__(self, instance): def get_members(self): return [ - attr for attr in dir(self.instance) + attr + for attr in dir(self.instance) if not callable(getattr(self.instance, attr)) and not attr.startswith("__") ] diff --git a/src/autofaker/dataframe.py b/src/autofaker/dataframe.py index f3fe56f..e763cad 100644 --- a/src/autofaker/dataframe.py +++ b/src/autofaker/dataframe.py @@ -15,8 +15,11 @@ def __init__(self, t, rows: int = 3, use_fake_data: bool = False): def generate(self): members = [ - attr for attr in dir(self.data[0]) - if dataclasses.is_dataclass(getattr(self.data[0], attr)) or not callable(getattr(self.data[0], attr)) and not attr.startswith("__") + attr + for attr in dir(self.data[0]) + if dataclasses.is_dataclass(getattr(self.data[0], attr)) + or not callable(getattr(self.data[0], attr)) + and not attr.startswith("__") ] rows = [] for d in self.data: diff --git a/src/autofaker/dates.py b/src/autofaker/dates.py index b9699f1..400efa7 100644 --- a/src/autofaker/dates.py +++ b/src/autofaker/dates.py @@ -5,27 +5,28 @@ def is_date_type(type_name) -> bool: - return type_name in [ - 'datetime', - 'date' - ] + return type_name in ["datetime", "date"] class DatetimeGenerator(TypeDataGeneratorBase): def generate(self): year = datetime.date.today().year - return datetime.datetime(random.randint(year - 10, year + 10), - random.randint(1, 12), - random.randint(1, 28), - random.randint(0, 23), - random.randint(0, 59), - random.randint(0, 59), - random.randint(0, 999)) + return datetime.datetime( + random.randint(year - 10, year + 10), + random.randint(1, 12), + random.randint(1, 28), + random.randint(0, 23), + random.randint(0, 59), + random.randint(0, 59), + random.randint(0, 999), + ) class DateGenerator(TypeDataGeneratorBase): def generate(self): year = datetime.date.today().year - return datetime.datetime(random.randint(year - 10, year + 10), - random.randint(1, 12), - random.randint(1, 28)) + return datetime.datetime( + random.randint(year - 10, year + 10), + random.randint(1, 12), + random.randint(1, 28), + ) diff --git a/src/autofaker/decorators.py b/src/autofaker/decorators.py index 7190fc9..5668886 100644 --- a/src/autofaker/decorators.py +++ b/src/autofaker/decorators.py @@ -33,9 +33,21 @@ def test_create_str_argument_using_decorator(self, text, number, decimal, boolea def decorator(function): def wrapper(*args): if __get_class_that_defined_method(function) is None: - return function(*tuple(__create_function_args(function, *tuple(types), use_fake_data=use_fake_data))) - return function(__get_test_class(*args), - *tuple(__create_function_args(function, *tuple(types), use_fake_data=use_fake_data))) + return function( + *tuple( + __create_function_args( + function, *tuple(types), use_fake_data=use_fake_data + ) + ) + ) + return function( + __get_test_class(*args), + *tuple( + __create_function_args( + function, *tuple(types), use_fake_data=use_fake_data + ) + ) + ) return wrapper @@ -65,9 +77,19 @@ def test_create_fake_arguments(self, text: str, number: int, decimal: float, boo def decorator(function): def wrapper(*args): if __get_class_that_defined_method(function) is None: - return function(*tuple(__create_function_args(function, *tuple(types), use_fake_data=True))) - return function(__get_test_class(*args), - *tuple(__create_function_args(function, *tuple(types), use_fake_data=True))) + return function( + *tuple( + __create_function_args( + function, *tuple(types), use_fake_data=True + ) + ) + ) + return function( + __get_test_class(*args), + *tuple( + __create_function_args(function, *tuple(types), use_fake_data=True) + ) + ) return wrapper @@ -85,7 +107,9 @@ def autopandas(t: object, rows: int = 3, use_fake_data: bool = False): def decorator(function): def wrapper(*args): - pdf = PandasDataFrameGenerator(t, rows, use_fake_data=use_fake_data).generate() + pdf = PandasDataFrameGenerator( + t, rows, use_fake_data=use_fake_data + ).generate() if __get_class_that_defined_method(function) is None: return function(pdf) return function(__get_test_class(*args), pdf) @@ -108,18 +132,22 @@ def fakepandas(t, rows: int = 3): def __get_test_class(*args): test_class = args[0] if issubclass(test_class.__class__, unittest.TestCase) is False: - raise NotImplementedError("This way of creating anonymous objects are only supported from unit tests") + raise NotImplementedError( + "This way of creating anonymous objects are only supported from unit tests" + ) return test_class def __get_class_that_defined_method(meth): if inspect.isfunction(meth): - cls = getattr(inspect.getmodule(meth), - meth.__qualname__.split('.', 1)[0].rsplit('.', 1)[0], - None) + cls = getattr( + inspect.getmodule(meth), + meth.__qualname__.split(".", 1)[0].rsplit(".", 1)[0], + None, + ) if isinstance(cls, type): return cls - return getattr(meth, '__objclass__', None) # handle special descriptor objects + return getattr(meth, "__objclass__", None) # handle special descriptor objects def __create_function_args(function, *types, use_fake_data: bool = False) -> List: @@ -133,5 +161,7 @@ def __create_function_args(function, *types, use_fake_data: bool = False) -> Lis if __get_class_that_defined_method(function) is None: pos = 0 if len(argtpes.args) - pos != len(values): - raise ValueError("Missing argument annotations. Please declare the type of every argument") + raise ValueError( + "Missing argument annotations. Please declare the type of every argument" + ) return values diff --git a/src/autofaker/enums.py b/src/autofaker/enums.py index 2c9f89d..81aa5b2 100644 --- a/src/autofaker/enums.py +++ b/src/autofaker/enums.py @@ -1,10 +1,11 @@ import random +from enum import Enum from autofaker.base import TypeDataGeneratorBase def is_enum(t) -> bool: - return t.__base__.__name__ == 'Enum' + return isinstance(t, Enum.__class__) class EnumGenerator(TypeDataGeneratorBase): diff --git a/src/autofaker/factory.py b/src/autofaker/factory.py index 0561cbb..2823833 100644 --- a/src/autofaker/factory.py +++ b/src/autofaker/factory.py @@ -1,52 +1,56 @@ from autofaker.builtins import ( - IntegerGenerator, - FloatGenerator, BooleanGenerator, + ByteArrayGenerator, + BytesGenerator, ComplexGenerator, + FloatGenerator, + IntegerGenerator, + MemoryViewGenerator, RangeGenerator, - BytesGenerator, - ByteArrayGenerator, - MemoryViewGenerator ) -from autofaker.fakes import FakeStringGenerator, StringGenerator, FakeIntegerGenerator +from autofaker.fakes import FakeIntegerGenerator, FakeStringGenerator, StringGenerator class BuiltinTypeDataGeneratorFactory: @staticmethod def is_supported(type_name) -> bool: return type_name in [ - 'int', - 'str', - 'float', - 'complex', - 'bool', - 'range', - 'bytes', - 'bytearray', - 'memoryview' + "int", + "str", + "float", + "complex", + "bool", + "range", + "bytes", + "bytearray", + "memoryview", ] @staticmethod def create(type_name, field_name: str = None, use_fake_data: bool = False): - if type_name == 'int': - return FakeIntegerGenerator() \ - if field_name is not None and use_fake_data is True \ + if type_name == "int": + return ( + FakeIntegerGenerator() + if field_name is not None and use_fake_data is True else IntegerGenerator() - if type_name == 'str': - return FakeStringGenerator(field_name) \ - if field_name is not None and use_fake_data is True \ + ) + if type_name == "str": + return ( + FakeStringGenerator(field_name) + if field_name is not None and use_fake_data is True else StringGenerator() - if type_name == 'float': + ) + if type_name == "float": return FloatGenerator() - if type_name == 'complex': + if type_name == "complex": return ComplexGenerator() - if type_name == 'bool': + if type_name == "bool": return BooleanGenerator() - if type_name == 'range': + if type_name == "range": return RangeGenerator() - if type_name == 'bytes': + if type_name == "bytes": return BytesGenerator() - if type_name == 'bytearray': + if type_name == "bytearray": return ByteArrayGenerator() - if type_name == 'memoryview': + if type_name == "memoryview": return MemoryViewGenerator() diff --git a/src/autofaker/generator.py b/src/autofaker/generator.py index 97d4d79..8321afb 100644 --- a/src/autofaker/generator.py +++ b/src/autofaker/generator.py @@ -4,33 +4,41 @@ import typing_inspect from autofaker.attributes import Attributes -from autofaker.dates import DatetimeGenerator, DateGenerator, is_date_type +from autofaker.dates import DateGenerator, DatetimeGenerator, is_date_type +from autofaker.enums import EnumGenerator, is_enum from autofaker.factory import BuiltinTypeDataGeneratorFactory from autofaker.fakes import TypeDataGeneratorBase -from autofaker.enums import EnumGenerator, is_enum class TypeDataGenerator: @staticmethod - def create(t, field_name: str = None, use_fake_data: bool = False) -> TypeDataGeneratorBase: + def create( + t, field_name: str = None, use_fake_data: bool = False + ) -> TypeDataGeneratorBase: type_name = TypeDataGenerator._get_type_name(t).lower() if BuiltinTypeDataGeneratorFactory.is_supported(type_name): - return BuiltinTypeDataGeneratorFactory.create(type_name, field_name, use_fake_data) + return BuiltinTypeDataGeneratorFactory.create( + type_name, field_name, use_fake_data + ) if is_date_type(type_name): - return TypeDataGenerator.create_datetime(type_name, field_name, use_fake_data) - if type_name == 'list': + return TypeDataGenerator.create_datetime( + type_name, field_name, use_fake_data + ) + if type_name == "list": return ListGenerator(t) if is_enum(t): return EnumGenerator(t) - return DataClassGenerator(t, use_fake_data=use_fake_data) \ - if dataclasses.is_dataclass(t) \ + return ( + DataClassGenerator(t, use_fake_data=use_fake_data) + if dataclasses.is_dataclass(t) else ClassGenerator(t, use_fake_data=use_fake_data) + ) @staticmethod def create_datetime(type_name, field_name: str = None, use_fake_data: bool = False): - if type_name == 'datetime': + if type_name == "datetime": return DatetimeGenerator() - if type_name == 'date': + if type_name == "date": return DateGenerator() @staticmethod @@ -39,7 +47,7 @@ def _get_type_name(t) -> str: return t.__name__ except Exception: attributes = dir(t) - if '_name' in attributes: + if "_name" in attributes: return t._name return type(t).__name__ @@ -53,9 +61,11 @@ def generate(self): args = [] fields = dataclasses.fields(self.cls) for field in fields: - generator = TypeDataGenerator.create(field.type, field.name, use_fake_data=self.use_fake_data) + generator = TypeDataGenerator.create( + field.type, field.name, use_fake_data=self.use_fake_data + ) args.append((field.name, field.type, generator.generate())) - name = self.cls.__module__ + '.' + self.cls.__qualname__ + name = self.cls.__module__ + "." + self.cls.__qualname__ instance = dataclasses.make_dataclass(name, args) return instance @@ -73,7 +83,7 @@ def generate(self): members = attributes.get_members() for member in members: attr = attributes.get_attribute(member) - if type(attr).__name__ == 'list': + if type(attr).__name__ == "list": for i in range(len(attr)): attr[i] = self._try_generate(attr[i]) else: @@ -82,9 +92,8 @@ def generate(self): def _is_supported(self): import pandas - unsupported_types = [ - pandas.core.frame.DataFrame - ] + + unsupported_types = [pandas.core.frame.DataFrame] for t in unsupported_types: if isinstance(self.instance, t): return False @@ -92,7 +101,9 @@ def _is_supported(self): def _try_generate(self, attr): try: - generator = TypeDataGenerator.create(type(attr), use_fake_data=self.use_fake_data) + generator = TypeDataGenerator.create( + type(attr), use_fake_data=self.use_fake_data + ) return generator.generate() except TypeError as e: print(e) @@ -112,11 +123,15 @@ def _create_with_init_args(self, cls): list_arg = typing_inspect.get_args(t) items = [] for _ in range(3): - generator = TypeDataGenerator.create(list_arg[0], use_fake_data=self.use_fake_data) + generator = TypeDataGenerator.create( + list_arg[0], use_fake_data=self.use_fake_data + ) items.append(generator.generate()) values.append(items) else: - generator = TypeDataGenerator.create(t, use_fake_data=self.use_fake_data) + generator = TypeDataGenerator.create( + t, use_fake_data=self.use_fake_data + ) value = generator.generate() values.append(value) self.instance = cls(*tuple(values)) @@ -130,6 +145,8 @@ def __init__(self, t, use_fake_data: bool = False): def generate(self): items = [] for _ in range(3): - generator = TypeDataGenerator.create(self.list_arg[0], use_fake_data=self.use_fake_data) + generator = TypeDataGenerator.create( + self.list_arg[0], use_fake_data=self.use_fake_data + ) items.append(generator.generate()) return items diff --git a/tests/pytests/test_decorator_anonymous_builtins.py b/tests/pytests/test_decorator_anonymous_builtins.py index 8bb2ae4..2ae8be4 100644 --- a/tests/pytests/test_decorator_anonymous_builtins.py +++ b/tests/pytests/test_decorator_anonymous_builtins.py @@ -1,10 +1,10 @@ -from datetime import datetime, date +from datetime import date, datetime from autofaker import autodata, fakedata - # Anonymous Primitives Via Decorator Tests + @autodata(str) def test_create_str_using_decorator(text): assert text is not None @@ -62,6 +62,7 @@ def test_create_date_using_decorator(d): # Anonymous Primitives Via Decorator With Fakes + @autodata(str, use_fake_data=True) def test_create_str_using_decorator_with_fake_data(text): assert text is not None @@ -119,8 +120,11 @@ def test_create_date_using_decorator_with_fake_data(d): # Multiple Anonymous Primitives Via Decorator Tests + @autodata(str, int, float, complex, range, bytes, bytearray, memoryview) -def test_create_primitives_using_decorator(text, number, decimal, complex_type, range_type, buffer, buffer2, memview): +def test_create_primitives_using_decorator( + text, number, decimal, complex_type, range_type, buffer, buffer2, memview +): assert text is not None assert number != 0 assert decimal != float() @@ -131,8 +135,12 @@ def test_create_primitives_using_decorator(text, number, decimal, complex_type, assert memview != memoryview(bytes()) -@autodata(str, int, float, complex, range, bytes, bytearray, memoryview, use_fake_data=True) -def test_create_primitives_using_decorator_with_fakes(text, number, decimal, complex_type, range_type, buffer, buffer2, memview): +@autodata( + str, int, float, complex, range, bytes, bytearray, memoryview, use_fake_data=True +) +def test_create_primitives_using_decorator_with_fakes( + text, number, decimal, complex_type, range_type, buffer, buffer2, memview +): assert text is not None assert number != 0 assert decimal != float() @@ -145,15 +153,18 @@ def test_create_primitives_using_decorator_with_fakes(text, number, decimal, com # Multiple Arguments Via Decorator Tests + @fakedata() -def test_create_anonymous_arguments_using_decorator(text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): +def test_create_anonymous_arguments_using_decorator( + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, +): print(text) print(number) print(decimal) @@ -169,14 +180,16 @@ def test_create_anonymous_arguments_using_decorator(text: str, @fakedata() -def test_create_fake_arguments_using_decorator(text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): +def test_create_fake_arguments_using_decorator( + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, +): print(text) print(number) print(decimal) @@ -192,14 +205,16 @@ def test_create_fake_arguments_using_decorator(text: str, @autodata() -def test_create_arguments_using_decorator(text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): +def test_create_arguments_using_decorator( + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, +): print(text) print(number) print(decimal) @@ -215,14 +230,16 @@ def test_create_arguments_using_decorator(text: str, @autodata(use_fake_data=True) -def test_create_arguments_using_decorator_with_fakes(text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): +def test_create_arguments_using_decorator_with_fakes( + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, +): print(text) print(number) print(decimal) diff --git a/tests/pytests/test_decorator_anonymous_data_classes.py b/tests/pytests/test_decorator_anonymous_data_classes.py index c9895bf..1d8e772 100644 --- a/tests/pytests/test_decorator_anonymous_data_classes.py +++ b/tests/pytests/test_decorator_anonymous_data_classes.py @@ -13,6 +13,7 @@ class DataClass: # Anonymous DataClass Via Decorator Test Cases + @autodata(DataClass) def test_create_data_class_using_decorator_returns_not_none(instance): assert instance is not None @@ -31,14 +32,18 @@ def test_create_data_class_returns_instance_with_new_values(instance): @autodata() -def test_create_data_class_argument_returns_instance_with_new_values(instance: DataClass): +def test_create_data_class_argument_returns_instance_with_new_values( + instance: DataClass, +): assert instance.id != int() assert instance.name != str() assert instance.text != str() @autodata() -def test_create_anonymous_data_class_returns_instance_with_new_values(instance: DataClass): +def test_create_anonymous_data_class_returns_instance_with_new_values( + instance: DataClass, +): assert instance.id != int() assert instance.name != str() assert instance.text != str() @@ -53,6 +58,7 @@ def test_create_fake_data_class_returns_instance_with_new_values(instance: DataC # Anonymous DataClass Via Decorator With Fakes Test Cases + @autodata(DataClass, use_fake_data=True) def test_create_data_class_using_decorator_returns_not_none_with_fake_data(instance): assert instance is not None @@ -70,14 +76,18 @@ def test_create_data_class_returns_instance_with_new_values_with_fake_data(insta @autodata(use_fake_data=True) -def test_create_data_class_argument_returns_instance_with_new_values_with_fake_data(instance: DataClass): +def test_create_data_class_argument_returns_instance_with_new_values_with_fake_data( + instance: DataClass, +): assert instance.id != int() assert instance.name != str() assert instance.text != str() @fakedata() -def test_create_fake_data_class_returns_instance_with_new_values_with_fake_data(instance: DataClass): +def test_create_fake_data_class_returns_instance_with_new_values_with_fake_data( + instance: DataClass, +): assert instance.id != int() assert instance.name != str() assert instance.text != str() diff --git a/tests/pytests/test_decorator_anonymous_data_classes_nested.py b/tests/pytests/test_decorator_anonymous_data_classes_nested.py index 87b7a8d..4aee076 100644 --- a/tests/pytests/test_decorator_anonymous_data_classes_nested.py +++ b/tests/pytests/test_decorator_anonymous_data_classes_nested.py @@ -29,6 +29,7 @@ class DoubleNestedClass: # Anonymous Nested Class Via Decorator Test Cases + @autodata(NestedClass) def test_create_nested_class_using_decorator_returns_not_none(instance): assert instance is not None @@ -47,21 +48,27 @@ def test_create_nested_class_returns_instance_with_new_values(instance): @autodata() -def test_create_nested_class_argument_returns_instance_with_new_values(instance: NestedClass): +def test_create_nested_class_argument_returns_instance_with_new_values( + instance: NestedClass, +): assert instance.id != 0 assert instance.name != str() assert instance.text != str() @autodata() -def test_create_anonymous_nested_class_returns_instance_with_new_values(instance: NestedClass): +def test_create_anonymous_nested_class_returns_instance_with_new_values( + instance: NestedClass, +): assert instance.id != 0 assert instance.name != str() assert instance.text != str() @fakedata() -def test_create_fake_nested_class_returns_instance_with_new_values(instance: NestedClass): +def test_create_fake_nested_class_returns_instance_with_new_values( + instance: NestedClass, +): assert instance.id != 0 assert instance.name != str() assert instance.text != str() @@ -69,6 +76,7 @@ def test_create_fake_nested_class_returns_instance_with_new_values(instance: Nes # Anonymous Double Nested Class Via Decorator With Fakes Test Cases + @autodata(DoubleNestedClass, use_fake_data=True) def test_create_double_nested_class_using_decorator_returns_not_none(instance): assert instance is not None @@ -87,12 +95,16 @@ def test_create_double_nested_class_returns_instance_with_new_values(instance): @autodata(use_fake_data=True) -def test_create_double_nested_class_argument_using_decorator_returns_not_none(instance: DoubleNestedClass): +def test_create_double_nested_class_argument_using_decorator_returns_not_none( + instance: DoubleNestedClass, +): assert instance is not None @fakedata() -def test_create_double_nested_class_argument_returns_instance_with_new_values(instance: DoubleNestedClass): +def test_create_double_nested_class_argument_returns_instance_with_new_values( + instance: DoubleNestedClass, +): assert instance.id != 0 assert instance.inner.inner.id != 0 assert instance.inner.inner.text != str() diff --git a/tests/pytests/test_decorator_anonymous_dataframe_pandas.py b/tests/pytests/test_decorator_anonymous_dataframe_pandas.py index 601ec7e..76eba89 100644 --- a/tests/pytests/test_decorator_anonymous_dataframe_pandas.py +++ b/tests/pytests/test_decorator_anonymous_dataframe_pandas.py @@ -2,13 +2,13 @@ import pandas -from autofaker import autopandas, fakepandas, autodata +from autofaker import autodata, autopandas, fakepandas class SimpleClassA: id = -1 - name: 'test' - text = 'test' + name: "test" + text = "test" class SimpleClassB: @@ -26,13 +26,16 @@ def __init__(self, a: SimpleClassA, b: SimpleClassB): # Anonymous Pandas DataFrame Via Decorator + @autopandas(SimpleClassA) def test_create_anonymous_pandas_dataframe_returns_not_none(df: pandas.DataFrame): assert df is not None @autopandas(SimpleClassA, 10) -def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty(df: pandas.DataFrame): +def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty( + df: pandas.DataFrame, +): assert len(df.index) != 0 @@ -42,7 +45,9 @@ def test_create_fake_pandas_dataframe_returns_not_none(df: pandas.DataFrame): @fakepandas(SimpleClassA, 10) -def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty(df: pandas.DataFrame): +def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty( + df: pandas.DataFrame, +): assert len(df.index) != 0 @@ -53,13 +58,17 @@ def test_can_create_anonymous_pandas_dataframes(cls): @autopandas(SimpleClassB) -def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_arguments(cls): +def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_arguments( + cls, +): print(cls) assert not cls.empty @autopandas(SimpleClassC) -def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments(cls): +def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments( + cls, +): print(cls) assert not cls.empty @@ -73,18 +82,23 @@ class DataClass: # Anonymous Pandas DataFrame Via Decorator From DataClass + @autopandas(DataClass) def test_create_anonymous_pandas_dataframe_returns_not_none(df: pandas.DataFrame): assert df is not None @autopandas(DataClass, 10) -def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty(df: pandas.DataFrame): +def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty( + df: pandas.DataFrame, +): assert len(df.index) != 0 @fakepandas(DataClass, 10) -def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty(df: pandas.DataFrame): +def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty( + df: pandas.DataFrame, +): assert len(df.index) != 0 @@ -95,12 +109,15 @@ def test_create_fake_pandas_dataframe_returns_not_none(df: pandas.DataFrame): # Autodata Decorator Ignores Pandas + @autodata() def test_autodata_decorator_ignores_pandas_dataframe(df: pandas.DataFrame): assert df is None @autodata() -def test_autodata_decorator_ignores_only_pandas_dataframe(text: str, df: pandas.DataFrame): +def test_autodata_decorator_ignores_only_pandas_dataframe( + text: str, df: pandas.DataFrame +): assert None is not text assert df is None diff --git a/tests/pytests/test_decorator_anonymous_enum_classes.py b/tests/pytests/test_decorator_anonymous_enum_classes.py index bc95519..f0db493 100644 --- a/tests/pytests/test_decorator_anonymous_enum_classes.py +++ b/tests/pytests/test_decorator_anonymous_enum_classes.py @@ -21,3 +21,22 @@ def test_create_enum_class_returns_not_none(sut): @autodata(Weekday) def test_create_enum_class_returns_instance(sut): assert isinstance(sut, Weekday) + + +class BasicEnum(Enum): + """empty""" + + +class InheritedEnum(BasicEnum): + VALUE_1 = 1 + VALUE_2 = 2 + + +@autodata(InheritedEnum) +def test_create_enum_class_returns_not_none(sut): + assert sut is not None + + +@autodata(InheritedEnum) +def test_create_enum_class_returns_instance(sut): + assert isinstance(sut, BasicEnum) diff --git a/tests/pytests/test_decorator_anonymous_nested_classes.py b/tests/pytests/test_decorator_anonymous_nested_classes.py index b45fa20..d9c09d5 100644 --- a/tests/pytests/test_decorator_anonymous_nested_classes.py +++ b/tests/pytests/test_decorator_anonymous_nested_classes.py @@ -3,26 +3,27 @@ class SimpleClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" class NestedClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" inner = SimpleClass() class DoubleNestedClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" inner = NestedClass() # Anonymous Nested Class Via Decorator + @autodata(NestedClass) def test_create_nested_class_using_decorator_returns_not_none(instance): assert instance is not None @@ -41,21 +42,27 @@ def test_create_nested_class_returns_instance_with_new_values(instance): @autodata() -def test_create_nested_class_argument_returns_instance_with_new_values(instance: NestedClass): +def test_create_nested_class_argument_returns_instance_with_new_values( + instance: NestedClass, +): assert instance.id != NestedClass().id assert instance.inner.id != SimpleClass().id assert instance.inner.text != SimpleClass().text @autodata() -def test_create_anonymous_nested_class_returns_instance_with_new_values(instance: NestedClass): +def test_create_anonymous_nested_class_returns_instance_with_new_values( + instance: NestedClass, +): assert instance.id != SimpleClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text @fakedata() -def test_create_fake_nested_class_returns_instance_with_new_values(instance: NestedClass): +def test_create_fake_nested_class_returns_instance_with_new_values( + instance: NestedClass, +): assert instance.id != NestedClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text @@ -63,18 +70,25 @@ def test_create_fake_nested_class_returns_instance_with_new_values(instance: Nes # Anonymous Double Nested Class Via Decorator With Fakes + @autodata(DoubleNestedClass, use_fake_data=True) -def test_create_double_nested_class_using_decorator_returns_not_none_with_fake_data(instance): +def test_create_double_nested_class_using_decorator_returns_not_none_with_fake_data( + instance, +): assert instance is not None @autodata(DoubleNestedClass, use_fake_data=True) -def test_create_double_nested_class_using_decorator_returns_instance_with_fake_data(instance): +def test_create_double_nested_class_using_decorator_returns_instance_with_fake_data( + instance, +): assert isinstance(instance, DoubleNestedClass) @autodata(DoubleNestedClass, use_fake_data=True) -def test_create_double_nested_class_returns_instance_with_new_values_with_fake_data(instance): +def test_create_double_nested_class_returns_instance_with_new_values_with_fake_data( + instance, +): assert instance.id != DoubleNestedClass().id assert instance.inner != DoubleNestedClass().inner assert instance.inner.id != DoubleNestedClass().id @@ -82,17 +96,23 @@ def test_create_double_nested_class_returns_instance_with_new_values_with_fake_d @autodata(use_fake_data=True) -def test_create_double_nested_class_argument_using_decorator_returns_not_none_with_fake_data(instance: DoubleNestedClass): +def test_create_double_nested_class_argument_using_decorator_returns_not_none_with_fake_data( + instance: DoubleNestedClass, +): assert instance is not None @autodata(use_fake_data=True) -def test_create_double_nested_class_argument_using_decorator_returns_instance_with_fake_data(instance: DoubleNestedClass): +def test_create_double_nested_class_argument_using_decorator_returns_instance_with_fake_data( + instance: DoubleNestedClass, +): assert isinstance(instance, DoubleNestedClass) @fakedata() -def test_create_double_nested_class_argument_returns_instance_with_new_values_with_fake_data(instance: DoubleNestedClass): +def test_create_double_nested_class_argument_returns_instance_with_new_values_with_fake_data( + instance: DoubleNestedClass, +): assert instance.id != DoubleNestedClass().id assert instance.inner != DoubleNestedClass().inner assert instance.inner.id != SimpleClass().id diff --git a/tests/pytests/test_decorator_anonymous_simple_classes.py b/tests/pytests/test_decorator_anonymous_simple_classes.py index a8fb235..47f223d 100644 --- a/tests/pytests/test_decorator_anonymous_simple_classes.py +++ b/tests/pytests/test_decorator_anonymous_simple_classes.py @@ -3,12 +3,13 @@ class SimpleClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" # Anonymous Simple Class Via Decorator + @autodata(SimpleClass) def test_create_simple_class_using_decorator_returns_not_none(instance): assert instance is not None @@ -27,21 +28,27 @@ def test_create_simple_class_returns_instance_with_new_values(instance): @autodata() -def test_create_simple_class_argument_returns_instance_with_new_values(instance: SimpleClass): +def test_create_simple_class_argument_returns_instance_with_new_values( + instance: SimpleClass, +): assert instance.id != SimpleClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text @autodata() -def test_create_anonymous_simple_class_returns_instance_with_new_values(instance: SimpleClass): +def test_create_anonymous_simple_class_returns_instance_with_new_values( + instance: SimpleClass, +): assert instance.id != SimpleClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text @fakedata() -def test_create_fake_simple_class_returns_instance_with_new_values(instance: SimpleClass): +def test_create_fake_simple_class_returns_instance_with_new_values( + instance: SimpleClass, +): assert instance.id != SimpleClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text @@ -49,6 +56,7 @@ def test_create_fake_simple_class_returns_instance_with_new_values(instance: Sim # Anonymous Simple Class Via Decorator With Fakes + @autodata(SimpleClass, use_fake_data=True) def test_create_simple_class_using_decorator_with_fake_data_returns_not_none(instance): assert instance is not None @@ -66,14 +74,18 @@ def test_create_simple_class_returns_instance_with_new_values_using_fake_data(in @autodata(use_fake_data=True) -def test_create_simple_class_argument_returns_instance_with_new_values_using_fake_data(instance: SimpleClass): +def test_create_simple_class_argument_returns_instance_with_new_values_using_fake_data( + instance: SimpleClass, +): assert instance.id != SimpleClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text @fakedata() -def test_create_fake_simple_class_returns_instance_with_new_values_using_fake_data(instance: SimpleClass): +def test_create_fake_simple_class_returns_instance_with_new_values_using_fake_data( + instance: SimpleClass, +): assert instance.id != SimpleClass().id assert instance.name != SimpleClass().name assert instance.text != SimpleClass().text diff --git a/tests/test_create_anonymous_complex_classes.py b/tests/test_create_anonymous_complex_classes.py index 63b5c26..69eae2e 100644 --- a/tests/test_create_anonymous_complex_classes.py +++ b/tests/test_create_anonymous_complex_classes.py @@ -68,7 +68,10 @@ def test_constructed_sut_inner_not_none(self): self.assertIsNotNone(Autodata.create(ConstructorWithClassArguments).inner) def test_constructed_sut_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithClassArguments).inner, ConstructorWithPrimitiveArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithClassArguments).inner, + ConstructorWithPrimitiveArguments, + ) class ConstructorWithNestedClassArguments: @@ -84,10 +87,16 @@ def test_constructed_sut_inner_not_none(self): self.assertIsNotNone(Autodata.create(ConstructorWithNestedClassArguments).inner) def test_constructed_sut_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithNestedClassArguments).inner, ConstructorWithClassArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithNestedClassArguments).inner, + ConstructorWithClassArguments, + ) def test_constructed_sut_inner_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithNestedClassArguments).inner.inner, ConstructorWithPrimitiveArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithNestedClassArguments).inner.inner, + ConstructorWithPrimitiveArguments, + ) class ConstructorWithDoubleNestedClassArguments: @@ -100,16 +109,29 @@ def test_can_construct_sut(self): self.assertIsNotNone(Autodata.create(ConstructorWithDoubleNestedClassArguments)) def test_constructed_sut_inner_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner) + self.assertIsNotNone( + Autodata.create(ConstructorWithDoubleNestedClassArguments).inner + ) def test_constructed_sut_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner, ConstructorWithNestedClassArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithDoubleNestedClassArguments).inner, + ConstructorWithNestedClassArguments, + ) def test_constructed_sut_inner_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner.inner, ConstructorWithClassArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithDoubleNestedClassArguments).inner.inner, + ConstructorWithClassArguments, + ) def test_constructed_sut_inner_inner_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner.inner.inner, ConstructorWithPrimitiveArguments) + self.assertIsInstance( + Autodata.create( + ConstructorWithDoubleNestedClassArguments + ).inner.inner.inner, + ConstructorWithPrimitiveArguments, + ) @dataclass @@ -133,13 +155,19 @@ def test_constructed_sut_id_not_none(self): self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.id) def test_constructed_sut_age_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.age) + self.assertIsNotNone( + Autodata.create(ConstructorWithDataClassArguments).data.age + ) def test_constructed_sut_name_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.name) + self.assertIsNotNone( + Autodata.create(ConstructorWithDataClassArguments).data.name + ) def test_constructed_sut_email_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.email) + self.assertIsNotNone( + Autodata.create(ConstructorWithDataClassArguments).data.email + ) class ConstructorWithListArguments: diff --git a/tests/test_create_anonymous_data_class_with_fakes.py b/tests/test_create_anonymous_data_class_with_fakes.py index d679eb2..51157c0 100644 --- a/tests/test_create_anonymous_data_class_with_fakes.py +++ b/tests/test_create_anonymous_data_class_with_fakes.py @@ -33,6 +33,7 @@ class DataClass: def is_uuid(s: str): try: from uuid import UUID + UUID(s) return True except ValueError: @@ -40,42 +41,59 @@ def is_uuid(s: str): class AnonymousDataClassWithFakesTestCase(unittest.TestCase): - def test_create_dataclass_name_returns_not_uuid(self): self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).name)) def test_create_dataclass_first_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).first_name)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).first_name) + ) def test_create_dataclass_last_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).last_name)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).last_name) + ) def test_create_dataclass_address_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).address)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).address) + ) def test_create_dataclass_job_returns_not_uuid(self): self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).job)) def test_create_dataclass_country_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).country)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).country) + ) def test_create_dataclass_currency_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).currency_name)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).currency_name) + ) def test_create_dataclass_currency_code_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).currency_code)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).currency_code) + ) def test_create_dataclass_email_returns_not_uuid(self): self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).email)) def test_create_dataclass_safe_email_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).safe_email)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).safe_email) + ) def test_create_dataclass_company_email_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).company_email)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).company_email) + ) def test_create_dataclass_hostname_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).hostname)) + self.assertFalse( + is_uuid(Autodata.create(DataClass, use_fake_data=True).hostname) + ) def test_create_dataclass_ipv4_returns_not_uuid(self): self.assertFalse(is_uuid(Autodata.create(DataClass, use_fake_data=True).ipv4)) diff --git a/tests/test_create_anonymous_data_classes.py b/tests/test_create_anonymous_data_classes.py index 23fc302..f6133e7 100644 --- a/tests/test_create_anonymous_data_classes.py +++ b/tests/test_create_anonymous_data_classes.py @@ -12,7 +12,6 @@ class DataClass: class AnonymousDataClassTestCase(unittest.TestCase): - def test_create_data_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(DataClass)) @@ -28,7 +27,7 @@ def test_create_many_data_class_returns_list(self): def test_create_many_data_class_returns_dataclass(self): data = Autodata.create(DataClass) self.assertNotEqual(0, data.id) - self.assertNotEqual('', data.text) + self.assertNotEqual("", data.text) @dataclass @@ -39,7 +38,6 @@ class NestedDataClass: class AnonymousNestedClassTestCase(unittest.TestCase): - def test_create_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(NestedDataClass)) @@ -53,7 +51,7 @@ def test_create_nested_class_returns_instance_with_new_nested_instance(self): result = Autodata.create(NestedDataClass) self.assertNotEqual(result.id, 0) self.assertNotEqual(result.inner.id, 0) - self.assertNotEqual(result.inner.text, '') + self.assertNotEqual(result.inner.text, "") @dataclass @@ -64,12 +62,13 @@ class DoubleNestedDataClass: class AnonymousDoubleNestedDataClassTestCase(unittest.TestCase): - def test_create_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(DoubleNestedDataClass)) def test_create_data_class_returns_dataclass(self): - self.assertTrue(dataclasses.is_dataclass(Autodata.create(DoubleNestedDataClass))) + self.assertTrue( + dataclasses.is_dataclass(Autodata.create(DoubleNestedDataClass)) + ) def test_create_nested_class_returns_instance_with_nested_not_none(self): self.assertIsNotNone(Autodata.create(DoubleNestedDataClass).inner) @@ -78,13 +77,12 @@ def test_create_nested_class_returns_instance_with_new_nested_instance(self): result = Autodata.create(DoubleNestedDataClass) self.assertNotEqual(result.id, 0) self.assertNotEqual(result.inner.id, 0) - self.assertNotEqual(result.inner.text, '') + self.assertNotEqual(result.inner.text, "") self.assertNotEqual(result.inner.inner.id, 0) - self.assertNotEqual(result.inner.inner.text, '') + self.assertNotEqual(result.inner.inner.text, "") class AnonymousInlineDataClassTestCase(unittest.TestCase): - def test_create_data_class_returns_not_none(self): @dataclass class InlineDataClass: @@ -125,4 +123,4 @@ class InlineDataClass: data = Autodata.create(InlineDataClass) self.assertNotEqual(0, data.id) - self.assertNotEqual('', data.text) + self.assertNotEqual("", data.text) diff --git a/tests/test_create_anonymous_data_classes_with_fakes.py b/tests/test_create_anonymous_data_classes_with_fakes.py index 5de43c1..221f536 100644 --- a/tests/test_create_anonymous_data_classes_with_fakes.py +++ b/tests/test_create_anonymous_data_classes_with_fakes.py @@ -33,6 +33,7 @@ class DataClass: def is_uuid(s: str): try: from uuid import UUID + UUID(s) return True except ValueError: @@ -40,51 +41,88 @@ def is_uuid(s: str): class AnonymousDataClassWithFakesTestCase(unittest.TestCase): - def test_create_many_dataclass_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].name)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].name) + ) def test_create_many_dataclass_first_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].first_name)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].first_name) + ) def test_create_many_dataclass_last_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].last_name)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].last_name) + ) def test_create_many_dataclass_address_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].address)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].address) + ) def test_create_many_dataclass_job_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].job)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].job) + ) def test_create_many_dataclass_country_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].country)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].country) + ) def test_create_many_dataclass_currency_name_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].currency_name)) + self.assertFalse( + is_uuid( + Autodata.create_many(DataClass, use_fake_data=True)[2].currency_name + ) + ) def test_create_many_dataclass_currency_code_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].currency_code)) + self.assertFalse( + is_uuid( + Autodata.create_many(DataClass, use_fake_data=True)[2].currency_code + ) + ) def test_create_many_dataclass_email_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].email)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].email) + ) def test_create_many_dataclass_safe_email_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].safe_email)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].safe_email) + ) def test_create_many_dataclass_company_email_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].company_email)) + self.assertFalse( + is_uuid( + Autodata.create_many(DataClass, use_fake_data=True)[2].company_email + ) + ) def test_create_many_dataclass_hostname_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].hostname)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].hostname) + ) def test_create_many_dataclass_ipv4_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].ipv4)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].ipv4) + ) def test_create_many_dataclass_ipv6_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].ipv6)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].ipv6) + ) def test_create_many_dataclass_text_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].text)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].text) + ) def test_create_many_dataclass_word_returns_not_uuid(self): - self.assertFalse(is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].word)) + self.assertFalse( + is_uuid(Autodata.create_many(DataClass, use_fake_data=True)[2].word) + ) diff --git a/tests/test_create_anonymous_dataframe_pandas.py b/tests/test_create_anonymous_dataframe_pandas.py index c8cd605..0a7f831 100644 --- a/tests/test_create_anonymous_dataframe_pandas.py +++ b/tests/test_create_anonymous_dataframe_pandas.py @@ -6,8 +6,8 @@ class SimpleClassA: id = -1 - name = 'test' - text = 'test' + name = "test" + text = "test" class SimpleClassB: @@ -24,7 +24,6 @@ def __init__(self, a: SimpleClassA, b: SimpleClassB): class CreateAnonymousPandasDataFrameTests(unittest.TestCase): - def test_create_anonymous_pandas_dataframe_returns_not_none(self): df = Autodata.create_pandas_dataframe(SimpleClassA) self.assertIsNotNone(df) @@ -37,20 +36,23 @@ def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty(self) df = Autodata.create_pandas_dataframe(SimpleClassA, 10) self.assertEqual(len(df.index), 10) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_arguments(self): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_arguments( + self, + ): df = Autodata.create_pandas_dataframe(SimpleClassB) - self.assertTrue('id' in df.columns) - self.assertTrue('name' in df.columns) - self.assertTrue('text' in df.columns) + self.assertTrue("id" in df.columns) + self.assertTrue("name" in df.columns) + self.assertTrue("text" in df.columns) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments(self): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments( + self, + ): df = Autodata.create_pandas_dataframe(SimpleClassC) - self.assertTrue('a' in df.columns) - self.assertTrue('b' in df.columns) + self.assertTrue("a" in df.columns) + self.assertTrue("b" in df.columns) class CreateFakePandasDataFrameTests(unittest.TestCase): - def test_create_fake_pandas_dataframe_returns_not_none(self): df = Autodata.create_pandas_dataframe(SimpleClassA, use_fake_data=True) self.assertIsNotNone(df) @@ -63,16 +65,20 @@ def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty(self): df = Autodata.create_pandas_dataframe(SimpleClassA, 10, use_fake_data=True) self.assertEqual(len(df.index), 10) - def test_can_create_fake_pandas_dataframes_from_class_with_constructor_arguments(self): + def test_can_create_fake_pandas_dataframes_from_class_with_constructor_arguments( + self, + ): df = Autodata.create_pandas_dataframe(SimpleClassB, use_fake_data=True) - self.assertTrue('id' in df.columns) - self.assertTrue('name' in df.columns) - self.assertTrue('text' in df.columns) + self.assertTrue("id" in df.columns) + self.assertTrue("name" in df.columns) + self.assertTrue("text" in df.columns) - def test_can_create_fake_pandas_dataframes_from_class_with_constructor_class_arguments(self): + def test_can_create_fake_pandas_dataframes_from_class_with_constructor_class_arguments( + self, + ): df = Autodata.create_pandas_dataframe(SimpleClassC, use_fake_data=True) - self.assertTrue('a' in df.columns) - self.assertTrue('b' in df.columns) + self.assertTrue("a" in df.columns) + self.assertTrue("b" in df.columns) @dataclass @@ -96,7 +102,6 @@ def __init__(self, a: DataClass, b: SimpleClassA, c: HybridClassA): class CreateAnonymousPandasDataFrameFromDataClassTests(unittest.TestCase): - def test_create_anonymous_pandas_dataframe_returns_not_none(self): df = Autodata.create_pandas_dataframe(DataClass) self.assertIsNotNone(df) @@ -109,20 +114,23 @@ def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty(self) df = Autodata.create_pandas_dataframe(DataClass, 10) self.assertEqual(len(df.index), 10) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments(self): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments( + self, + ): df = Autodata.create_pandas_dataframe(HybridClassA) - self.assertTrue('b' in df.columns) - self.assertTrue('a' in df.columns) + self.assertTrue("b" in df.columns) + self.assertTrue("a" in df.columns) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_hybrid_class_arguments(self): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_hybrid_class_arguments( + self, + ): df = Autodata.create_pandas_dataframe(HybridClassB) - self.assertTrue('c' in df.columns) - self.assertTrue('b' in df.columns) - self.assertTrue('a' in df.columns) + self.assertTrue("c" in df.columns) + self.assertTrue("b" in df.columns) + self.assertTrue("a" in df.columns) class CreateFakePandasDataFrameFromDataClassTests(unittest.TestCase): - def test_create_fake_pandas_dataframe_returns_not_none(self): df = Autodata.create_pandas_dataframe(DataClass, use_fake_data=True) self.assertIsNotNone(df) @@ -135,13 +143,17 @@ def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty(self): df = Autodata.create_pandas_dataframe(DataClass, 10, use_fake_data=True) self.assertEqual(len(df.index), 10) - def test_can_create_fake_pandas_dataframes_from_class_with_constructor_class_arguments(self): + def test_can_create_fake_pandas_dataframes_from_class_with_constructor_class_arguments( + self, + ): df = Autodata.create_pandas_dataframe(HybridClassA, use_fake_data=True) - self.assertTrue('b' in df.columns) - self.assertTrue('a' in df.columns) + self.assertTrue("b" in df.columns) + self.assertTrue("a" in df.columns) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_hybrid_class_arguments(self): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_hybrid_class_arguments( + self, + ): df = Autodata.create_pandas_dataframe(HybridClassB, use_fake_data=True) - self.assertTrue('c' in df.columns) - self.assertTrue('b' in df.columns) - self.assertTrue('a' in df.columns) + self.assertTrue("c" in df.columns) + self.assertTrue("b" in df.columns) + self.assertTrue("a" in df.columns) diff --git a/tests/test_create_anonymous_dataframe_with_fakes.py b/tests/test_create_anonymous_dataframe_with_fakes.py index 64ec872..158f079 100644 --- a/tests/test_create_anonymous_dataframe_with_fakes.py +++ b/tests/test_create_anonymous_dataframe_with_fakes.py @@ -33,6 +33,7 @@ class DataClass: def is_uuid(s: str): try: from uuid import UUID + UUID(s) return True except ValueError: @@ -40,7 +41,6 @@ def is_uuid(s: str): class AnonymousDataClassWithFakesTestCase(unittest.TestCase): - def test_create_pandas_dataframe_returns_not_none(self): pdf = Autodata.create_pandas_dataframe(DataClass, use_fake_data=True) print() diff --git a/tests/test_create_anonymous_dates.py b/tests/test_create_anonymous_dates.py index 38c9e3a..d5b1614 100644 --- a/tests/test_create_anonymous_dates.py +++ b/tests/test_create_anonymous_dates.py @@ -1,5 +1,5 @@ import unittest -from datetime import datetime, date +from datetime import date, datetime from autofaker import Autodata diff --git a/tests/test_create_anonymous_enum_classes.py b/tests/test_create_anonymous_enum_classes.py index 86bcf55..fc34ae4 100644 --- a/tests/test_create_anonymous_enum_classes.py +++ b/tests/test_create_anonymous_enum_classes.py @@ -15,9 +15,25 @@ class Weekday(Enum): class AnonymousWeekdayTestCase(unittest.TestCase): - def test_create_enum_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(Weekday)) def test_create_enum_class_returns_instance(self): self.assertIsInstance(Autodata.create(Weekday), Weekday) + + +class BasicEnum(Enum): + """empty""" + + +class InheritedEnum(BasicEnum): + VALUE_1 = 1 + VALUE_2 = 2 + + +class AnonymousEnumInheritanceTestCase(unittest.TestCase): + def test_create_enum_class_returns_not_none(self): + self.assertIsNotNone(Autodata.create(InheritedEnum)) + + def test_create_enum_class_returns_instance(self): + self.assertIsInstance(Autodata.create(InheritedEnum), BasicEnum) diff --git a/tests/test_create_anonymous_lists.py b/tests/test_create_anonymous_lists.py index 622ee5d..3fbe2a6 100644 --- a/tests/test_create_anonymous_lists.py +++ b/tests/test_create_anonymous_lists.py @@ -1,7 +1,7 @@ import unittest from abc import abstractmethod from dataclasses import dataclass -from datetime import datetime, date +from datetime import date, datetime from typing import List from autofaker import Autodata diff --git a/tests/test_create_anonymous_nested_classes.py b/tests/test_create_anonymous_nested_classes.py index f4ab479..86aeec6 100644 --- a/tests/test_create_anonymous_nested_classes.py +++ b/tests/test_create_anonymous_nested_classes.py @@ -5,23 +5,22 @@ class SimpleClass: id = -1 - text = 'test' + text = "test" class NestedClass: id = -1 - text = 'test' + text = "test" inner = SimpleClass() class DoubleNestedClass: id = -1 - text = 'test' + text = "test" inner = NestedClass() class AnonymousNestedClassTestCase(unittest.TestCase): - def test_create_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(NestedClass)) @@ -39,7 +38,6 @@ def test_create_nested_class_returns_instance_with_new_nested_instance(self): class AnonymousDoubleNestedClassTestCase(unittest.TestCase): - def test_create_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(DoubleNestedClass)) diff --git a/tests/test_create_anonymous_nested_classes_with_lists.py b/tests/test_create_anonymous_nested_classes_with_lists.py index 06b8210..26683b3 100644 --- a/tests/test_create_anonymous_nested_classes_with_lists.py +++ b/tests/test_create_anonymous_nested_classes_with_lists.py @@ -5,28 +5,29 @@ class SimpleClass: id = -1 - text = 'test' + text = "test" class NestedWithCollectionClass: id = -1 - text = 'test' + text = "test" inner = [SimpleClass(), SimpleClass()] class NestedWithNestedCollectionClass: id = -1 - text = 'test' + text = "test" inner = [NestedWithCollectionClass(), NestedWithCollectionClass()] class AnonymousNestedClassWithCollectionTestCase(unittest.TestCase): - def test_create_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(NestedWithCollectionClass)) def test_create_nested_class_returns_instance(self): - self.assertIsInstance(Autodata.create(NestedWithCollectionClass), NestedWithCollectionClass) + self.assertIsInstance( + Autodata.create(NestedWithCollectionClass), NestedWithCollectionClass + ) def test_create_nested_class_returns_instance_with_nested_not_none(self): self.assertIsNotNone(Autodata.create(NestedWithCollectionClass).inner) @@ -44,21 +45,26 @@ def test_create_nested_class_returns_instance_with_new_nested_instance(self): class AnonymousNestedClassWithNestedCollectionTestCase(unittest.TestCase): - def test_create_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create(NestedWithCollectionClass)) def test_create_nested_class_returns_instance(self): - self.assertIsInstance(Autodata.create(NestedWithCollectionClass), NestedWithCollectionClass) + self.assertIsInstance( + Autodata.create(NestedWithCollectionClass), NestedWithCollectionClass + ) def test_create_nested_class_returns_instance_with_inner_not_none(self): self.assertIsNotNone(Autodata.create(NestedWithNestedCollectionClass).inner) def test_create_nested_class_returns_instance_with_inner_not_empty(self): - self.assertNotEqual(0, len(Autodata.create(NestedWithNestedCollectionClass).inner)) + self.assertNotEqual( + 0, len(Autodata.create(NestedWithNestedCollectionClass).inner) + ) def test_create_nested_class_returns_instance_with_nested_inner_not_empty(self): - self.assertNotEqual(0, len(Autodata.create(NestedWithNestedCollectionClass).inner[0].inner)) + self.assertNotEqual( + 0, len(Autodata.create(NestedWithNestedCollectionClass).inner[0].inner) + ) def test_create_nested_class_returns_instance_with_new_nested_instance(self): result = Autodata.create(NestedWithNestedCollectionClass) diff --git a/tests/test_create_anonymous_simple_classes.py b/tests/test_create_anonymous_simple_classes.py index d9dd5f0..5f01919 100644 --- a/tests/test_create_anonymous_simple_classes.py +++ b/tests/test_create_anonymous_simple_classes.py @@ -4,7 +4,6 @@ class AnonymousSimpleClassTestCase(unittest.TestCase): - def test_create_local_class_returns_not_none(self): class X: pass @@ -31,4 +30,4 @@ def test_create_simple_class_returns_instance_with_new_values(self): class SimpleClass: id = -1 - text = 'test' + text = "test" diff --git a/tests/test_create_anonymous_sut.py b/tests/test_create_anonymous_sut.py index c6119cf..9797910 100644 --- a/tests/test_create_anonymous_sut.py +++ b/tests/test_create_anonymous_sut.py @@ -11,7 +11,6 @@ def add(self, number1: int, number2: int): class CalculatorTests(unittest.TestCase): - def test_can_add_two_numbers(self): numbers = Autodata.create_many(int, 2) sut = Autodata.create(Calculator) @@ -24,24 +23,30 @@ def test_can_add_two_numbers_using_test_arguments(self, sut, number1, number2): self.assertEqual(number1 + number2, result) @autodata - def test_can_add_two_numbers_using_annotated_arguments(self, sut: Calculator, number1: int, number2: int): + def test_can_add_two_numbers_using_annotated_arguments( + self, sut: Calculator, number1: int, number2: int + ): result = sut.add(number1, number2) self.assertEqual(number1 + number2, result) @autodata - def test_can_add_two_numbers_using_anonymous_arguments(self, sut: Calculator, number1: int, number2: int): + def test_can_add_two_numbers_using_anonymous_arguments( + self, sut: Calculator, number1: int, number2: int + ): result = sut.add(number1, number2) self.assertEqual(number1 + number2, result) @fakedata - def test_can_add_two_numbers_using_fake_arguments(self, sut: Calculator, number1: int, number2: int): + def test_can_add_two_numbers_using_fake_arguments( + self, sut: Calculator, number1: int, number2: int + ): result = sut.add(number1, number2) self.assertEqual(number1 + number2, result) class Person: age = 10 - name = 'test' + name = "test" def get_introduction(self): return f"Hi! My name is {self.name} and I'm {self.age} years old" @@ -67,7 +72,6 @@ def introduce(self): class StaffTests(unittest.TestCase): - def test_introduce_everyone(self): people = Autodata.create_many(Person) sut = Autodata.create(Staff) @@ -110,7 +114,10 @@ def test_constructed_sut_inner_not_none(self): self.assertIsNotNone(Autodata.create(ConstructorWithClassArguments).inner) def test_constructed_sut_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithClassArguments).inner, ConstructorWithPrimitiveArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithClassArguments).inner, + ConstructorWithPrimitiveArguments, + ) class ConstructorWithNestedClassArguments: @@ -126,10 +133,16 @@ def test_constructed_sut_inner_not_none(self): self.assertIsNotNone(Autodata.create(ConstructorWithNestedClassArguments).inner) def test_constructed_sut_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithNestedClassArguments).inner, ConstructorWithClassArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithNestedClassArguments).inner, + ConstructorWithClassArguments, + ) def test_constructed_sut_inner_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithNestedClassArguments).inner.inner, ConstructorWithPrimitiveArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithNestedClassArguments).inner.inner, + ConstructorWithPrimitiveArguments, + ) class ConstructorWithDoubleNestedClassArguments: @@ -142,16 +155,29 @@ def test_can_construct_sut(self): self.assertIsNotNone(Autodata.create(ConstructorWithDoubleNestedClassArguments)) def test_constructed_sut_inner_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner) + self.assertIsNotNone( + Autodata.create(ConstructorWithDoubleNestedClassArguments).inner + ) def test_constructed_sut_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner, ConstructorWithNestedClassArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithDoubleNestedClassArguments).inner, + ConstructorWithNestedClassArguments, + ) def test_constructed_sut_inner_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner.inner, ConstructorWithClassArguments) + self.assertIsInstance( + Autodata.create(ConstructorWithDoubleNestedClassArguments).inner.inner, + ConstructorWithClassArguments, + ) def test_constructed_sut_inner_inner_inner_has_correct_type(self): - self.assertIsInstance(Autodata.create(ConstructorWithDoubleNestedClassArguments).inner.inner.inner, ConstructorWithPrimitiveArguments) + self.assertIsInstance( + Autodata.create( + ConstructorWithDoubleNestedClassArguments + ).inner.inner.inner, + ConstructorWithPrimitiveArguments, + ) @dataclass @@ -175,13 +201,19 @@ def test_constructed_sut_id_not_none(self): self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.id) def test_constructed_sut_age_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.age) + self.assertIsNotNone( + Autodata.create(ConstructorWithDataClassArguments).data.age + ) def test_constructed_sut_name_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.name) + self.assertIsNotNone( + Autodata.create(ConstructorWithDataClassArguments).data.name + ) def test_constructed_sut_email_not_none(self): - self.assertIsNotNone(Autodata.create(ConstructorWithDataClassArguments).data.email) + self.assertIsNotNone( + Autodata.create(ConstructorWithDataClassArguments).data.email + ) class ConstructorWithListArguments: diff --git a/tests/test_create_many_anonymous_dates.py b/tests/test_create_many_anonymous_dates.py index 95fd996..58c49a9 100644 --- a/tests/test_create_many_anonymous_dates.py +++ b/tests/test_create_many_anonymous_dates.py @@ -30,7 +30,9 @@ def test_create_many_with_size_returns(self): def test_create_many_returns_list_with_non_defaults(self): if self.getType() is None: return - self.assertNotEqual(Autodata.create_many(self.getType()), [self.getType()(1970, 1, 1)]) + self.assertNotEqual( + Autodata.create_many(self.getType()), [self.getType()(1970, 1, 1)] + ) class AnonymousDatetimeListTestCase(CreateManyTestCase): diff --git a/tests/test_create_many_anonymous_nested_classes.py b/tests/test_create_many_anonymous_nested_classes.py index 11956f3..eb47a09 100644 --- a/tests/test_create_many_anonymous_nested_classes.py +++ b/tests/test_create_many_anonymous_nested_classes.py @@ -5,23 +5,22 @@ class SimpleClass: id = -1 - text = 'test' + text = "test" class NestedClass: id = -1 - text = 'test' + text = "test" inner = SimpleClass() class DoubleNestedClass: id = -1 - text = 'test' + text = "test" inner = NestedClass() class AnonymousNestedClassTestCase(unittest.TestCase): - def test_create_many_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create_many(NestedClass)) @@ -42,7 +41,6 @@ def test_create_many_nested_class_returns_instance_with_new_nested_instance(self class AnonymousDoubleNestedClassTestCase(unittest.TestCase): - def test_create_many_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create_many(DoubleNestedClass)) @@ -61,7 +59,9 @@ def test_create_many_nested_class_returns_instance_with_new_nested_instance(self self.assertNotEqual(item.id, DoubleNestedClass().id) self.assertNotEqual(item.inner, NestedClass()) - def test_create_many_nested_class_returns_instance_with_new_double_nested_instance(self): + def test_create_many_nested_class_returns_instance_with_new_double_nested_instance( + self, + ): result = Autodata.create_many(DoubleNestedClass) for item in result: self.assertNotEqual(item.id, DoubleNestedClass().id) diff --git a/tests/test_create_many_anonymous_nested_classes_with_lists.py b/tests/test_create_many_anonymous_nested_classes_with_lists.py index 8f7274a..8c07012 100644 --- a/tests/test_create_many_anonymous_nested_classes_with_lists.py +++ b/tests/test_create_many_anonymous_nested_classes_with_lists.py @@ -5,23 +5,22 @@ class SimpleClass: id = -1 - text = 'test' + text = "test" class NestedWithCollectionClass: id = -1 - text = 'test' + text = "test" inner = [SimpleClass(), SimpleClass()] class NestedWithNestedCollectionClass: id = -1 - text = 'test' + text = "test" inner = [NestedWithCollectionClass(), NestedWithCollectionClass()] class AnonymousNestedClassWithCollectionTestCase(unittest.TestCase): - def test_create_many_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create_many(NestedWithCollectionClass)) @@ -49,7 +48,6 @@ def test_create_many_nested_class_returns_instances_with_new_nested_instance(sel class AnonymousNestedClassWithNestedCollectionTestCase(unittest.TestCase): - def test_create_many_nested_class_returns_not_none(self): self.assertIsNotNone(Autodata.create_many(NestedWithCollectionClass)) @@ -66,7 +64,9 @@ def test_create_many_nested_class_returns_instances_with_inner_not_empty(self): for item in result: self.assertNotEqual(0, len(item.inner)) - def test_create_many_nested_class_returns_instances_with_nested_inner_not_empty(self): + def test_create_many_nested_class_returns_instances_with_nested_inner_not_empty( + self, + ): result = Autodata.create_many(NestedWithNestedCollectionClass) for item in result: for cls in item.inner: diff --git a/tests/test_create_many_anonymous_simple_classes.py b/tests/test_create_many_anonymous_simple_classes.py index 7d8792c..e0ef1dd 100644 --- a/tests/test_create_many_anonymous_simple_classes.py +++ b/tests/test_create_many_anonymous_simple_classes.py @@ -6,7 +6,7 @@ class SimpleClass: id = -1 - text = 'test' + text = "test" class AnonymousSimpleClassTestCase(unittest.TestCase): diff --git a/tests/test_decorator_exceptions.py b/tests/test_decorator_exceptions.py index 76c3569..7db701d 100644 --- a/tests/test_decorator_exceptions.py +++ b/tests/test_decorator_exceptions.py @@ -3,7 +3,7 @@ import pandas -from autofaker import autodata, fakedata, autopandas, fakepandas +from autofaker import autodata, autopandas, fakedata, fakepandas @dataclass @@ -29,9 +29,9 @@ def autopandas_test_method(df: pandas.DataFrame): class AnonymousPrimitivesViaDecoratorThrowsExceptionsTests(unittest.TestCase): - def test_autodata_throws_error_when_decorating_non_testmethod(self): with self.assertRaises(NotImplementedError): + class X: @autodata(str, str, str) def not_test_method(self): @@ -41,6 +41,7 @@ def not_test_method(self): def test_autodata_throws_error_when_used_without_arguments(self): with self.assertRaises(NotImplementedError): + class X: @autodata() def not_test_method(self): @@ -50,6 +51,7 @@ def not_test_method(self): def test_autodata_throws_error_when_used_without_arguments_annotation(self): with self.assertRaises(ValueError): + class X(unittest.TestCase): @autodata() def not_test_method(self, text, number, decimal): @@ -59,6 +61,7 @@ def not_test_method(self, text, number, decimal): def test_fakedata_throws_error_when_decorating_non_testmethod(self): with self.assertRaises(NotImplementedError): + class X: @fakedata(str, str, str) def not_test_method(self): @@ -68,6 +71,7 @@ def not_test_method(self): def test_fakedata_throws_error_when_used_without_arguments(self): with self.assertRaises(NotImplementedError): + class X: @fakedata() def not_test_method(self): @@ -77,6 +81,7 @@ def not_test_method(self): def test_fakedata_throws_error_when_used_without_arguments_annotation(self): with self.assertRaises(ValueError): + class X(unittest.TestCase): @fakedata() def not_test_method(self, text, number, decimal): @@ -87,10 +92,11 @@ def not_test_method(self, text, number, decimal): def test_autopandas_throws_error_when_decorating_non_testmethod(self): class SimpleClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" with self.assertRaises(NotImplementedError): + class X: @autopandas(SimpleClass) def not_test_method(self, df): @@ -101,10 +107,11 @@ def not_test_method(self, df): def test_fakepandas_throws_error_when_decorating_non_testmethod(self): class SimpleClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" with self.assertRaises(NotImplementedError): + class X: @fakepandas(SimpleClass) def not_test_method(self, df): diff --git a/tests/unittests/test_decorator_anonymous_builtins.py b/tests/unittests/test_decorator_anonymous_builtins.py index a6c9298..ffe310d 100644 --- a/tests/unittests/test_decorator_anonymous_builtins.py +++ b/tests/unittests/test_decorator_anonymous_builtins.py @@ -1,11 +1,10 @@ import unittest -from datetime import datetime, date +from datetime import date, datetime from autofaker import autodata, fakedata class AnonymousPrimitivesViaDecoratorTests(unittest.TestCase): - @autodata(str) def test_create_str_using_decorator(self, text): self.assertIsNotNone(text) @@ -52,7 +51,6 @@ def test_create_date_using_decorator(self, d): class AnonymousPrimitivesViaDecoratorWithFakesTests(unittest.TestCase): - @autodata(str, use_fake_data=True) def test_create_str_using_decorator(self, text): self.assertIsNotNone(text) @@ -99,9 +97,10 @@ def test_create_date_using_decorator(self, d): class MultipleAnonymousPrimitivesViaDecoratorTests(unittest.TestCase): - @autodata(str, int, float, complex, range, bytes, bytearray, memoryview) - def test_create_primitives_using_decorator(self, text, number, decimal, complex_type, range_type, buffer, buffer2, memview): + def test_create_primitives_using_decorator( + self, text, number, decimal, complex_type, range_type, buffer, buffer2, memview + ): self.assertIsNotNone(text) self.assertNotEqual(number, 0) self.assertNotEqual(decimal, float()) @@ -111,8 +110,20 @@ def test_create_primitives_using_decorator(self, text, number, decimal, complex_ self.assertNotEqual(buffer2, bytearray()) self.assertNotEqual(memview, memoryview(bytes())) - @autodata(str, int, float, complex, range, bytes, bytearray, memoryview, use_fake_data=True) - def test_create_primitives_using_decorator_with_fakes(self, text, number, decimal, complex_type, range_type, buffer, buffer2, memview): + @autodata( + str, + int, + float, + complex, + range, + bytes, + bytearray, + memoryview, + use_fake_data=True, + ) + def test_create_primitives_using_decorator_with_fakes( + self, text, number, decimal, complex_type, range_type, buffer, buffer2, memview + ): self.assertIsNotNone(text) self.assertNotEqual(number, 0) self.assertNotEqual(decimal, float()) @@ -124,17 +135,18 @@ def test_create_primitives_using_decorator_with_fakes(self, text, number, decima class MultipleArgumentsViaDecoratorTests(unittest.TestCase): - @fakedata() - def test_create_anonymous_arguments_using_decorator(self, - text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): + def test_create_anonymous_arguments_using_decorator( + self, + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, + ): print(text) print(number) print(decimal) @@ -149,15 +161,17 @@ def test_create_anonymous_arguments_using_decorator(self, self.assertNotEqual(memview, memoryview(bytes())) @fakedata() - def test_create_fake_arguments_using_decorator(self, - text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): + def test_create_fake_arguments_using_decorator( + self, + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, + ): print(text) print(number) print(decimal) @@ -172,15 +186,17 @@ def test_create_fake_arguments_using_decorator(self, self.assertNotEqual(memview, memoryview(bytes())) @autodata() - def test_create_arguments_using_decorator(self, - text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): + def test_create_arguments_using_decorator( + self, + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, + ): print(text) print(number) print(decimal) @@ -195,15 +211,17 @@ def test_create_arguments_using_decorator(self, self.assertNotEqual(memview, memoryview(bytes())) @autodata(use_fake_data=True) - def test_create_arguments_using_decorator_with_fakes(self, - text: str, - number: int, - decimal: float, - complex_type: complex, - range_type: range, - buffer: bytes, - buffer2: bytearray, - memview: memoryview): + def test_create_arguments_using_decorator_with_fakes( + self, + text: str, + number: int, + decimal: float, + complex_type: complex, + range_type: range, + buffer: bytes, + buffer2: bytearray, + memview: memoryview, + ): print(text) print(number) print(decimal) diff --git a/tests/unittests/test_decorator_anonymous_data_classes.py b/tests/unittests/test_decorator_anonymous_data_classes.py index a371336..a210369 100644 --- a/tests/unittests/test_decorator_anonymous_data_classes.py +++ b/tests/unittests/test_decorator_anonymous_data_classes.py @@ -13,7 +13,6 @@ class DataClass: class AnonymousDataClassViaDecoratorTestCase(unittest.TestCase): - @autodata(DataClass) def test_create_data_class_using_decorator_returns_not_none(self, instance): self.assertIsNotNone(instance) @@ -29,26 +28,31 @@ def test_create_data_class_returns_instance_with_new_values(self, instance): self.assertNotEqual(instance.text, str()) @autodata() - def test_create_data_class_argument_returns_instance_with_new_values(self, instance: DataClass): + def test_create_data_class_argument_returns_instance_with_new_values( + self, instance: DataClass + ): self.assertNotEqual(instance.id, int()) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) @autodata() - def test_create_anonymous_data_class_returns_instance_with_new_values(self, instance: DataClass): + def test_create_anonymous_data_class_returns_instance_with_new_values( + self, instance: DataClass + ): self.assertNotEqual(instance.id, int()) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) @fakedata() - def test_create_fake_data_class_returns_instance_with_new_values(self, instance: DataClass): + def test_create_fake_data_class_returns_instance_with_new_values( + self, instance: DataClass + ): self.assertNotEqual(instance.id, int()) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) class AnonymousDataClassViaDecoratorWithFakesTestCase(unittest.TestCase): - @autodata(DataClass, use_fake_data=True) def test_create_data_class_using_decorator_returns_not_none(self, instance): self.assertIsNotNone(instance) @@ -63,13 +67,17 @@ def test_create_data_class_returns_instance_with_new_values(self, instance): self.assertNotEqual(instance.text, str()) @autodata(use_fake_data=True) - def test_create_data_class_argument_returns_instance_with_new_values(self, instance: DataClass): + def test_create_data_class_argument_returns_instance_with_new_values( + self, instance: DataClass + ): self.assertNotEqual(instance.id, int()) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) @fakedata() - def test_create_fake_data_class_returns_instance_with_new_values(self, instance: DataClass): + def test_create_fake_data_class_returns_instance_with_new_values( + self, instance: DataClass + ): self.assertNotEqual(instance.id, int()) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) diff --git a/tests/unittests/test_decorator_anonymous_data_classes_nested.py b/tests/unittests/test_decorator_anonymous_data_classes_nested.py index 08a1136..4e33d4a 100644 --- a/tests/unittests/test_decorator_anonymous_data_classes_nested.py +++ b/tests/unittests/test_decorator_anonymous_data_classes_nested.py @@ -29,7 +29,6 @@ class DoubleNestedClass: class AnonymousNestedClassViaDecoratorTestCase(unittest.TestCase): - @autodata(NestedClass) def test_create_nested_class_using_decorator_returns_not_none(self, instance): self.assertIsNotNone(instance) @@ -45,28 +44,35 @@ def test_create_nested_class_returns_instance_with_new_values(self, instance): self.assertNotEqual(instance.inner.text, str()) @autodata() - def test_create_nested_class_argument_returns_instance_with_new_values(self, instance: NestedClass): + def test_create_nested_class_argument_returns_instance_with_new_values( + self, instance: NestedClass + ): self.assertNotEqual(instance.id, 0) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) @autodata() - def test_create_anonymous_nested_class_returns_instance_with_new_values(self, instance: NestedClass): + def test_create_anonymous_nested_class_returns_instance_with_new_values( + self, instance: NestedClass + ): self.assertNotEqual(instance.id, 0) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) @fakedata() - def test_create_fake_nested_class_returns_instance_with_new_values(self, instance: NestedClass): + def test_create_fake_nested_class_returns_instance_with_new_values( + self, instance: NestedClass + ): self.assertNotEqual(instance.id, 0) self.assertNotEqual(instance.name, str()) self.assertNotEqual(instance.text, str()) class AnonymousDoubleNestedClassViaDecoratorWithFakesTestCase(unittest.TestCase): - @autodata(DoubleNestedClass, use_fake_data=True) - def test_create_double_nested_class_using_decorator_returns_not_none(self, instance): + def test_create_double_nested_class_using_decorator_returns_not_none( + self, instance + ): self.assertIsNotNone(instance) @autodata(DoubleNestedClass, use_fake_data=True) @@ -74,17 +80,23 @@ def test_create_nested_class_using_decorator_returns_dataclass(self, instance): self.assertTrue(dataclasses.is_dataclass(instance)) @autodata(DoubleNestedClass, use_fake_data=True) - def test_create_double_nested_class_returns_instance_with_new_values(self, instance): + def test_create_double_nested_class_returns_instance_with_new_values( + self, instance + ): self.assertNotEqual(instance.id, 0) self.assertNotEqual(instance.inner.inner.id, 0) self.assertNotEqual(instance.inner.inner.text, str()) @autodata(use_fake_data=True) - def test_create_double_nested_class_argument_using_decorator_returns_not_none(self, instance: DoubleNestedClass): + def test_create_double_nested_class_argument_using_decorator_returns_not_none( + self, instance: DoubleNestedClass + ): self.assertIsNotNone(instance) @fakedata() - def test_create_double_nested_class_argument_returns_instance_with_new_values(self, instance: DoubleNestedClass): + def test_create_double_nested_class_argument_returns_instance_with_new_values( + self, instance: DoubleNestedClass + ): self.assertNotEqual(instance.id, 0) self.assertNotEqual(instance.inner.inner.id, 0) self.assertNotEqual(instance.inner.inner.text, str()) diff --git a/tests/unittests/test_decorator_anonymous_dataframe_pandas.py b/tests/unittests/test_decorator_anonymous_dataframe_pandas.py index 8ab1f80..250f49f 100644 --- a/tests/unittests/test_decorator_anonymous_dataframe_pandas.py +++ b/tests/unittests/test_decorator_anonymous_dataframe_pandas.py @@ -3,13 +3,13 @@ import pandas -from autofaker import autopandas, fakepandas, autodata +from autofaker import autodata, autopandas, fakepandas class SimpleClassA: id = -1 - name: 'test' - text = 'test' + name: "test" + text = "test" class SimpleClassB: @@ -26,13 +26,16 @@ def __init__(self, a: SimpleClassA, b: SimpleClassB): class AnonymousPandasDataFrameViaDecoratorTests(unittest.TestCase): - @autopandas(SimpleClassA) - def test_create_anonymous_pandas_dataframe_returns_not_none(self, df: pandas.DataFrame): + def test_create_anonymous_pandas_dataframe_returns_not_none( + self, df: pandas.DataFrame + ): self.assertIsNotNone(df) @autopandas(SimpleClassA, 10) - def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty(self, df: pandas.DataFrame): + def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty( + self, df: pandas.DataFrame + ): self.assertNotEqual(len(df.index), 0) @fakepandas(SimpleClassA) @@ -40,7 +43,9 @@ def test_create_fake_pandas_dataframe_returns_not_none(self, df: pandas.DataFram self.assertIsNotNone(df) @fakepandas(SimpleClassA, 10) - def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty(self, df: pandas.DataFrame): + def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty( + self, df: pandas.DataFrame + ): self.assertNotEqual(len(df.index), 0) @autopandas(SimpleClassA) @@ -48,11 +53,15 @@ def test_can_create_anonymous_pandas_dataframes(self, cls): self.assertIsNotNone(cls) @autopandas(SimpleClassB) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_arguments(self, cls): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_arguments( + self, cls + ): self.assertIsNotNone(cls) @autopandas(SimpleClassC) - def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments(self, cls): + def test_can_create_anonymous_pandas_dataframes_from_class_with_constructor_class_arguments( + self, cls + ): self.assertIsNotNone(cls) @@ -64,17 +73,22 @@ class DataClass: class AnonymousPandasDataFrameViaDecoratorFromDataClassTests(unittest.TestCase): - @autopandas(DataClass) - def test_create_anonymous_pandas_dataframe_returns_not_none(self, df: pandas.DataFrame): + def test_create_anonymous_pandas_dataframe_returns_not_none( + self, df: pandas.DataFrame + ): self.assertIsNotNone(df) @autopandas(DataClass, 10) - def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty(self, df: pandas.DataFrame): + def test_create_anonymous_pandas_dataframe_with_rowcount_returns_not_empty( + self, df: pandas.DataFrame + ): self.assertNotEqual(len(df.index), 0) @fakepandas(DataClass, 10) - def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty(self, df: pandas.DataFrame): + def test_create_fake_pandas_dataframe_with_rowcount_returns_not_empty( + self, df: pandas.DataFrame + ): self.assertNotEqual(len(df.index), 0) @fakepandas(DataClass) @@ -83,12 +97,13 @@ def test_create_fake_pandas_dataframe_returns_not_none(self, df: pandas.DataFram class AutodataDecoratorIgnoresPandas(unittest.TestCase): - @autodata() def test_autodata_decorator_ignores_pandas_dataframe(self, df: pandas.DataFrame): self.assertIsNone(df) @autodata() - def test_autodata_decorator_ignores_only_pandas_dataframe(self, text: str, df: pandas.DataFrame): + def test_autodata_decorator_ignores_only_pandas_dataframe( + self, text: str, df: pandas.DataFrame + ): self.assertIsNotNone(text) self.assertIsNone(df) diff --git a/tests/unittests/test_decorator_anonymous_enum_classes.py b/tests/unittests/test_decorator_anonymous_enum_classes.py index b3480ee..04201f3 100644 --- a/tests/unittests/test_decorator_anonymous_enum_classes.py +++ b/tests/unittests/test_decorator_anonymous_enum_classes.py @@ -15,7 +15,6 @@ class Weekday(Enum): class AnonymousWeekdayTestCase(unittest.TestCase): - @autodata(Weekday) def test_create_enum_class_returns_not_none(self, sut): self.assertIsNotNone(sut) diff --git a/tests/unittests/test_decorator_anonymous_nested_classes.py b/tests/unittests/test_decorator_anonymous_nested_classes.py index 88294f0..a9278a6 100644 --- a/tests/unittests/test_decorator_anonymous_nested_classes.py +++ b/tests/unittests/test_decorator_anonymous_nested_classes.py @@ -5,26 +5,25 @@ class SimpleClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" class NestedClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" inner = SimpleClass() class DoubleNestedClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" inner = NestedClass() class AnonymousNestedClassViaDecoratorTestCase(unittest.TestCase): - @autodata(NestedClass) def test_create_nested_class_using_decorator_returns_not_none(self, instance): self.assertIsNotNone(instance) @@ -40,19 +39,25 @@ def test_create_nested_class_returns_instance_with_new_values(self, instance): self.assertNotEqual(instance.inner.text, SimpleClass().text) @autodata() - def test_create_nested_class_argument_returns_instance_with_new_values(self, instance: NestedClass): + def test_create_nested_class_argument_returns_instance_with_new_values( + self, instance: NestedClass + ): self.assertNotEqual(instance.id, NestedClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text) @autodata() - def test_create_anonymous_nested_class_returns_instance_with_new_values(self, instance: NestedClass): + def test_create_anonymous_nested_class_returns_instance_with_new_values( + self, instance: NestedClass + ): self.assertNotEqual(instance.id, SimpleClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text) @fakedata() - def test_create_fake_nested_class_returns_instance_with_new_values(self, instance: NestedClass): + def test_create_fake_nested_class_returns_instance_with_new_values( + self, instance: NestedClass + ): print(instance) self.assertNotEqual(instance.id, NestedClass().id) self.assertNotEqual(instance.name, SimpleClass().name) @@ -60,32 +65,43 @@ def test_create_fake_nested_class_returns_instance_with_new_values(self, instanc class AnonymousDoubleNestedClassViaDecoratorWithFakesTestCase(unittest.TestCase): - @autodata(DoubleNestedClass, use_fake_data=True) - def test_create_double_nested_class_using_decorator_returns_not_none(self, instance): + def test_create_double_nested_class_using_decorator_returns_not_none( + self, instance + ): self.assertIsNotNone(instance) @autodata(DoubleNestedClass, use_fake_data=True) - def test_create_double_nested_class_using_decorator_returns_instance(self, instance): + def test_create_double_nested_class_using_decorator_returns_instance( + self, instance + ): self.assertIsInstance(instance, DoubleNestedClass) @autodata(DoubleNestedClass, use_fake_data=True) - def test_create_double_nested_class_returns_instance_with_new_values(self, instance): + def test_create_double_nested_class_returns_instance_with_new_values( + self, instance + ): self.assertNotEqual(instance.id, DoubleNestedClass().id) self.assertNotEqual(instance.inner, DoubleNestedClass().inner) self.assertNotEqual(instance.inner.inner.id, SimpleClass().id) self.assertNotEqual(instance.inner.inner.text, SimpleClass().text) @autodata(use_fake_data=True) - def test_create_double_nested_class_argument_using_decorator_returns_not_none(self, instance: DoubleNestedClass): + def test_create_double_nested_class_argument_using_decorator_returns_not_none( + self, instance: DoubleNestedClass + ): self.assertIsNotNone(instance) @autodata(use_fake_data=True) - def test_create_double_nested_class_argument_using_decorator_returns_instance(self, instance: DoubleNestedClass): + def test_create_double_nested_class_argument_using_decorator_returns_instance( + self, instance: DoubleNestedClass + ): self.assertIsInstance(instance, DoubleNestedClass) @fakedata() - def test_create_double_nested_class_argument_returns_instance_with_new_values(self, instance: DoubleNestedClass): + def test_create_double_nested_class_argument_returns_instance_with_new_values( + self, instance: DoubleNestedClass + ): self.assertNotEqual(instance.id, DoubleNestedClass().id) self.assertNotEqual(instance.inner, DoubleNestedClass().inner) self.assertNotEqual(instance.inner.inner.id, SimpleClass().id) diff --git a/tests/unittests/test_decorator_anonymous_simple_classes.py b/tests/unittests/test_decorator_anonymous_simple_classes.py index 35e239f..127dbd1 100644 --- a/tests/unittests/test_decorator_anonymous_simple_classes.py +++ b/tests/unittests/test_decorator_anonymous_simple_classes.py @@ -5,12 +5,11 @@ class SimpleClass: id = -1 - name = 'name' - text = 'test' + name = "name" + text = "test" class AnonymousSimpleClassViaDecoratorTestCase(unittest.TestCase): - @autodata(SimpleClass) def test_create_simple_class_using_decorator_returns_not_none(self, instance): self.assertIsNotNone(instance) @@ -26,26 +25,31 @@ def test_create_simple_class_returns_instance_with_new_values(self, instance): self.assertNotEqual(instance.text, SimpleClass().text) @autodata() - def test_create_simple_class_argument_returns_instance_with_new_values(self, instance: SimpleClass): + def test_create_simple_class_argument_returns_instance_with_new_values( + self, instance: SimpleClass + ): self.assertNotEqual(instance.id, SimpleClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text) @autodata() - def test_create_anonymous_simple_class_returns_instance_with_new_values(self, instance: SimpleClass): + def test_create_anonymous_simple_class_returns_instance_with_new_values( + self, instance: SimpleClass + ): self.assertNotEqual(instance.id, SimpleClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text) @fakedata() - def test_create_fake_simple_class_returns_instance_with_new_values(self, instance: SimpleClass): + def test_create_fake_simple_class_returns_instance_with_new_values( + self, instance: SimpleClass + ): self.assertNotEqual(instance.id, SimpleClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text) class AnonymousSimpleClassViaDecoratorWithFakesTestCase(unittest.TestCase): - @autodata(SimpleClass, use_fake_data=True) def test_create_simple_class_using_decorator_returns_not_none(self, instance): self.assertIsNotNone(instance) @@ -60,13 +64,17 @@ def test_create_simple_class_returns_instance_with_new_values(self, instance): self.assertNotEqual(instance.text, SimpleClass().text) @autodata(use_fake_data=True) - def test_create_simple_class_argument_returns_instance_with_new_values(self, instance: SimpleClass): + def test_create_simple_class_argument_returns_instance_with_new_values( + self, instance: SimpleClass + ): self.assertNotEqual(instance.id, SimpleClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text) @fakedata() - def test_create_fake_simple_class_returns_instance_with_new_values(self, instance: SimpleClass): + def test_create_fake_simple_class_returns_instance_with_new_values( + self, instance: SimpleClass + ): self.assertNotEqual(instance.id, SimpleClass().id) self.assertNotEqual(instance.name, SimpleClass().name) self.assertNotEqual(instance.text, SimpleClass().text)