-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
71 lines (55 loc) · 1.89 KB
/
test.py
File metadata and controls
71 lines (55 loc) · 1.89 KB
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
import unittest
import os
from example_engine import ExampleEngine
from ortei import EngineEvaluator
# TestCase를 작성
class EngineTests(unittest.TestCase):
def setUp(self):
"""테스트 시작되기 전 파일 작성"""
self.engin = ExampleEngine()
def tearDown(self):
"""테스트 종료 후 파일 삭제 """
try:
pass
except:
pass
def test_set_input_data(self):
self.engin.set_input_data("fake_input")
def test_convert_data2input(self):
self.engin.convert_data2input()
def test_move_host2device(self):
self.engin.move_host2device()
def test_inference(self):
self.engin.inference()
def test_move_device2host(self):
self.engin.move_device2host()
def test_convert_output2data(self):
self.engin.convert_output2data()
def test_get_output_data(self):
self.engin.get_output_data()
class EvaluatorTests(unittest.TestCase):
def setUp(self):
"""테스트 시작되기 전 파일 작성"""
self.engin = ExampleEngine()
self.dataset = [i for i in range(100)]
self.evaluator = EngineEvaluator(self.engin)
self.test_result_path = f"./temp_test_run_and_save_result.csv"
def tearDown(self):
"""테스트 종료 후 파일 삭제 """
csv_path = self.test_result_path
try:
os.remove(csv_path)
assert not os.path.exists(csv_path)
except Exception as ex:
print(ex)
def test_run_and_save(self):
test_result_path = self.test_result_path
evaluator = self.evaluator
dataset = self.dataset
evaluator.run(dataset)
evaluator.save_testdata(test_result_path)
assert os.path.exists(test_result_path)
os.system(f"cat {test_result_path}")
# unittest를 실행
if __name__ == '__main__':
unittest.main()