-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_main.py
45 lines (37 loc) · 1.4 KB
/
test_main.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
# coding:utf-8
import time
import calendar
import unittest
import main
class TestMain(unittest.TestCase):
"""mainのテスト"""
def test_invalid_month_and_days(self):
'''無効な月日を入力された時のテスト'''
# month, day, expected return value
test_inputs = [
[ 0, 0, 1 ],
[ 1, 1, 0 ],
[ 2, 30, 1],
[ -1, 1, 1],
[ 1, -1, 1],
[ 13, 1, 1],
]
for ti in test_inputs:
md = f'{ti[0]}/{ti[1]}'
print( f'======== {md} ========' )
ret = main.main_process( [md] )
self.assertEqual( ret, ti[2], f"[test_monthAndDays]Failed Assertion: with {md}" )
def test_alldays(self):
'''全ての月日を入力して正しく取得できるかどうかテスト'''
for month in range( 1, 12+1 ):
mr = calendar.monthrange( 2020, month ) # 2020年は閏年
# print( f'======== {year}/{month}: {mr[1]} ========' )
for day in range( 1, mr[1]+1 ):
md = f'{month}/{day}'
print( f'======== {md} ========' )
ret = main.main_process( [ md ] )
self.assertEqual( ret, 0, f"[test_allDays]Failed Assertion: with {md}" )
time.sleep(2.0)
# main
if __name__ == '__main__':
unittest.main(verbosity=2)