-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_generator.py
77 lines (62 loc) · 1.86 KB
/
test_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""This file is generated by test_case_generator"""
from typing import NamedTuple, Callable
from unit_gen.unittest_case_generator import generate_test_case
def kek(foo: int, bar: str) -> str:
return str(foo) + bar
def test_generate_test_case():
class Args(NamedTuple):
func: Callable
class Test(NamedTuple):
name: str
args: Args
want: str
cases: tuple[Test, ...] = (
Test(
"Test on itself",
Args(generate_test_case),
"""\n
def test_generate_test_case():
class Args(NamedTuple):
func: Callable
class Test(NamedTuple):
name: str
args: Args
want: str
cases: tuple[Test] = (
# TODO: add cases here
)
print(f"running test cases for generate_test_case function:")
for case in cases:
if (v := generate_test_case(*case.args)) != case.want:
print(f"{case.name} generate_test_case got {v}, wanted {case.want}")
""",
),
Test(
"Test on kek func",
Args(kek),
"""def test_kek():
class Args(NamedTuple):
foo: int
bar: str
class Test(NamedTuple):
name: str
args: Args
want: str
cases: tuple[Test] = (
# TODO: add cases here
)
print(f"running test cases for kek function:\\n")
for case in cases:
if (v := func(*case.args)) != case.want:
print(f"{case.name} kek got {v} wanted {case.want}")
print("Test complited")
""",
),
)
print(f"running test cases for generate_test_case function:\n")
for case in cases:
if (v := generate_test_case(*case.args)) != case.want:
print(f"{case.name} generate_test_case got {v} wanted {case.want}\n")
print("Test complited")
if __name__ == "__main__":
test_generate_test_case()