Update test style

This commit is contained in:
Andras Schmelczer 2022-07-05 13:14:05 +02:00
parent f188724d4b
commit 2db2253578
18 changed files with 778 additions and 686 deletions

View file

@ -1,4 +1,3 @@
import unittest
from functools import lru_cache
import pytest
@ -11,55 +10,62 @@ from great_ai import (
)
class TestHumanReadableToByte(unittest.TestCase):
def test_create_simple_cases(self) -> None:
@GreatAI.create
def hello_world(name: str) -> str:
return f"Hello {name}!"
def test_create_trivial_cases() -> None:
@GreatAI.create
def hello_world_1(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
assert hello_world_1("andras").output == "Hello andras!"
@GreatAI.create
def hello_world(name):
return f"Hello {name}!"
@GreatAI.create
def hello_world_2(name):
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
assert hello_world_2("andras").output == "Hello andras!"
@GreatAI.create()
def hello_world(name: str) -> str:
return f"Hello {name}!"
@GreatAI.create()
def hello_world_3(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
assert hello_world_3("andras").output == "Hello andras!"
def test_create_with_other_decorator(self) -> None:
@GreatAI.create
@lru_cache
def hello_world(name: str) -> str:
return f"Hello {name}!"
@GreatAI.create()
def hello_world_4(name):
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
assert hello_world_4("andras").output == "Hello andras!"
@lru_cache
@GreatAI.create()
def hello_world(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
def test_create_with_other_decorator() -> None:
@GreatAI.create
@lru_cache
def hello_world(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
@lru_cache
@GreatAI.create()
def hello_world(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
def test_with_parameter() -> None:
@GreatAI.create
@parameter("name", validator=lambda v: len(v) > 5)
def hello_world(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
with pytest.raises(ArgumentValidationError):
hello_world("short")
with pytest.raises(WrongDecoratorOrderError):
def test_with_parameter(self) -> None:
@GreatAI.create
@parameter("name", validator=lambda v: len(v) > 5)
@GreatAI.create
def hello_world(name: str) -> str:
return f"Hello {name}!"
assert hello_world("andras").output == "Hello andras!"
with pytest.raises(ArgumentValidationError):
hello_world("short")
with pytest.raises(WrongDecoratorOrderError):
@parameter("name", validator=lambda v: len(v) > 5)
@GreatAI.create
def hello_world(name: str) -> str:
return f"Hello {name}!"