Tests: fixed unit.log print.
This commit is contained in:
@@ -6,6 +6,7 @@ import time
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.php import TestApplicationPHP
|
||||
|
||||
class TestPHPApplication(TestApplicationPHP):
|
||||
@@ -444,7 +445,7 @@ class TestPHPApplication(TestApplicationPHP):
|
||||
r'012345', self.get()['body']
|
||||
), 'disable_classes before'
|
||||
|
||||
def test_php_application_error_log(self):
|
||||
def test_php_application_error_log(self, temp_dir):
|
||||
self.load('error_log')
|
||||
|
||||
assert self.get()['status'] == 200, 'status'
|
||||
@@ -453,13 +454,13 @@ class TestPHPApplication(TestApplicationPHP):
|
||||
|
||||
assert self.get()['status'] == 200, 'status 2'
|
||||
|
||||
self.stop()
|
||||
unit_stop()
|
||||
|
||||
pattern = r'\d{4}\/\d\d\/\d\d\s\d\d:.+\[notice\].+Error in application'
|
||||
|
||||
assert self.wait_for_record(pattern) is not None, 'errors print'
|
||||
|
||||
with open(self.temp_dir + '/unit.log', 'r', errors='ignore') as f:
|
||||
with open(temp_dir + '/unit.log', 'r', errors='ignore') as f:
|
||||
errs = re.findall(pattern, f.read())
|
||||
|
||||
assert len(errs) == 2, 'error_log count'
|
||||
@@ -507,12 +508,12 @@ class TestPHPApplication(TestApplicationPHP):
|
||||
assert resp['status'] == 200, 'status'
|
||||
assert resp['body'] != '', 'body not empty'
|
||||
|
||||
def test_php_application_extension_check(self):
|
||||
def test_php_application_extension_check(self, temp_dir):
|
||||
self.load('phpinfo')
|
||||
|
||||
assert self.get(url='/index.wrong')['status'] != 200, 'status'
|
||||
|
||||
new_root = self.temp_dir + "/php"
|
||||
new_root = temp_dir + "/php"
|
||||
os.mkdir(new_root)
|
||||
shutil.copy(option.test_dir + '/php/phpinfo/index.wrong', new_root)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user