proto.py (1635:97afbb6c5a15) proto.py (1654:fc7d0578e124)
1import os
2import re
3import time
4
5from conftest import option
6from unit.control import TestControl
7
8
9class TestApplicationProto(TestControl):
10 def sec_epoch(self):
11 return time.mktime(time.gmtime())
12
13 def date_to_sec_epoch(self, date, template='%a, %d %b %Y %H:%M:%S %Z'):
14 return time.mktime(time.strptime(date, template))
15
16 def search_in_log(self, pattern, name='unit.log'):
1import os
2import re
3import time
4
5from conftest import option
6from unit.control import TestControl
7
8
9class TestApplicationProto(TestControl):
10 def sec_epoch(self):
11 return time.mktime(time.gmtime())
12
13 def date_to_sec_epoch(self, date, template='%a, %d %b %Y %H:%M:%S %Z'):
14 return time.mktime(time.strptime(date, template))
15
16 def search_in_log(self, pattern, name='unit.log'):
17 with open(self.temp_dir + '/' + name, 'r', errors='ignore') as f:
17 with open(option.temp_dir + '/' + name, 'r', errors='ignore') as f:
18 return re.search(pattern, f.read())
19
20 def wait_for_record(self, pattern, name='unit.log'):
21 for i in range(50):
22 found = self.search_in_log(pattern, name)
23
24 if found is not None:
25 break

--- 29 unchanged lines hidden ---
18 return re.search(pattern, f.read())
19
20 def wait_for_record(self, pattern, name='unit.log'):
21 for i in range(50):
22 found = self.search_in_log(pattern, name)
23
24 if found is not None:
25 break

--- 29 unchanged lines hidden ---