summaryrefslogtreecommitdiffhomepage
path: root/test/unit/applications/proto.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2021-05-27 17:03:24 +0300
committerAndrei Belov <defan@nginx.com>2021-05-27 17:03:24 +0300
commit0afb4b5790c5a37ba6b880eb351a65fe00521fbe (patch)
treec7e0b6bed92ee62a5e8b13c945c4134e68554cec /test/unit/applications/proto.py
parent21ff5e086ece7188df3b7338d228fa4fb7f886af (diff)
parentd06e55dfa3692e27a92ff6c2534bb083416bc0c8 (diff)
downloadunit-1.24.0-1.tar.gz
unit-1.24.0-1.tar.bz2
Merged with the default branch.1.24.0-1
Diffstat (limited to 'test/unit/applications/proto.py')
-rw-r--r--test/unit/applications/proto.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/unit/applications/proto.py b/test/unit/applications/proto.py
index 5c400621..92754c03 100644
--- a/test/unit/applications/proto.py
+++ b/test/unit/applications/proto.py
@@ -4,6 +4,7 @@ import time
from unit.control import TestControl
from unit.option import option
+from unit.log import Log
class TestApplicationProto(TestControl):
@@ -15,18 +16,23 @@ class TestApplicationProto(TestControl):
def date_to_sec_epoch(self, date, template='%a, %d %b %Y %H:%M:%S %Z'):
return time.mktime(time.strptime(date, template))
+ def findall(self, pattern, name='unit.log'):
+ with Log.open(name) as f:
+ return re.findall(pattern, f.read())
+
def search_in_log(self, pattern, name='unit.log'):
- with open(option.temp_dir + '/' + name, 'r', errors='ignore') as f:
+ with Log.open(name) as f:
return re.search(pattern, f.read())
def wait_for_record(self, pattern, name='unit.log', wait=150):
- for i in range(wait):
- found = self.search_in_log(pattern, name)
+ with Log.open(name) as f:
+ for i in range(wait):
+ found = re.search(pattern, f.read())
- if found is not None:
- break
+ if found is not None:
+ break
- time.sleep(0.1)
+ time.sleep(0.1)
return found