From e1f6f90eaf0591ab8c05935303241877f793a4cf Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Sat, 19 Oct 2024 21:58:54 +0200 Subject: [PATCH] Specify return types --- tests/test_create_anonymous_builtins.py | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/test_create_anonymous_builtins.py b/tests/test_create_anonymous_builtins.py index aa2da68..da6ea22 100644 --- a/tests/test_create_anonymous_builtins.py +++ b/tests/test_create_anonymous_builtins.py @@ -1,80 +1,80 @@ import unittest from abc import abstractmethod +from typing import Type from autofaker import Autodata class CreateTestCase(unittest.TestCase): @abstractmethod - def getType(self): + def getType(self) -> Type: pass def test_create_returns_not_none(self): - if self.getType() is None: - return - self.assertIsNotNone(Autodata.create(self.getType())) + if self.getType() is not None: + self.assertIsNotNone(Autodata.create(self.getType())) def test_create_returns_not_type(self): - if self.getType() is None: - return - self.assertNotIsInstance(Autodata.create(self.getType()), type) + if self.getType() is not None: + self.assertNotIsInstance(Autodata.create(self.getType()), type) def test_create_returns_not_default(self): - if self.getType() is None or self.getType() is bool or range: - return - self.assertNotEqual(Autodata.create(self.getType()), self.getType()()) + if (self.getType() is not None + and not bool + and not range): + self.assertNotEqual(Autodata.create(self.getType()), self.getType()()) class AnonymousIntegerTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[int]: return int class AnonymousStringTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[str]: return str class AnonymousFloatTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[float]: return float class AnonymousBooleanTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[bool]: return bool class AnonymousComplexTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[complex]: return complex class AnonymousRangeTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[range]: return range class AnonymousBytesTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[bytes]: return bytes class AnonymousByteArrayTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[bytearray]: return bytearray class AnonymousMemoryViewTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[memoryview]: return memoryview class AnonymousSetTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[set]: return set class AnonymousFrozensetTestCase(CreateTestCase): - def getType(self): + def getType(self) -> Type[frozenset]: return frozenset