Tests: removed unused code in unit.py.
This commit is contained in:
@@ -4,10 +4,7 @@ import unit
|
||||
class TestUnitConfiguration(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
|
||||
u.check_modules('python')
|
||||
u.check_version('0.5')
|
||||
unit.TestUnit().check_modules('python')
|
||||
|
||||
def test_json_leading_zero(self):
|
||||
self.assertIn('error', self.conf('00'), 'leading zero')
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import unittest
|
||||
import unit
|
||||
|
||||
class TestUnitBasic(unit.TestUnitControl):
|
||||
class TestUnitPHPBasic(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
|
||||
u.check_modules('php')
|
||||
u.check_version('0.5')
|
||||
unit.TestUnit().check_modules('php')
|
||||
|
||||
conf_app = {
|
||||
"app": {
|
||||
|
||||
@@ -2,13 +2,10 @@ import time
|
||||
import unittest
|
||||
import unit
|
||||
|
||||
class TestUnitApplication(unit.TestUnitControl):
|
||||
class TestUnitPythonApplication(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
|
||||
u.check_modules('python')
|
||||
u.check_version('0.5')
|
||||
unit.TestUnit().check_modules('python')
|
||||
|
||||
def conf_with_name(self, name):
|
||||
self.conf({
|
||||
|
||||
@@ -3,15 +3,12 @@ import time
|
||||
import unittest
|
||||
import unit
|
||||
|
||||
class TestUnitApplication(unit.TestUnitControl):
|
||||
class TestUnitPythonAtExit(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
unit.TestUnit().check_modules('python')
|
||||
|
||||
u.check_modules('python')
|
||||
u.check_version('0.5')
|
||||
|
||||
def test_python_application(self):
|
||||
def test_python_atexit(self):
|
||||
code, name = """
|
||||
import atexit
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import unittest
|
||||
import unit
|
||||
|
||||
class TestUnitBasic(unit.TestUnitControl):
|
||||
class TestUnitPythonBasic(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
|
||||
u.check_modules('python')
|
||||
u.check_version('0.5')
|
||||
unit.TestUnit().check_modules('python')
|
||||
|
||||
conf_app = {
|
||||
"app": {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import unittest
|
||||
import unit
|
||||
|
||||
class TestUnitApplication(unit.TestUnitControl):
|
||||
class TestUnitPythonKeepalive(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
|
||||
u.check_modules('python')
|
||||
u.check_version('0.5')
|
||||
unit.TestUnit().check_modules('python')
|
||||
|
||||
def test_python_keepalive_body(self):
|
||||
code, name = """
|
||||
|
||||
@@ -4,13 +4,10 @@ import subprocess
|
||||
import unittest
|
||||
import unit
|
||||
|
||||
class TestUnitProcman(unit.TestUnitControl):
|
||||
class TestUnitPythonProcman(unit.TestUnitControl):
|
||||
|
||||
def setUpClass():
|
||||
u = unit.TestUnit()
|
||||
|
||||
u.check_modules('python')
|
||||
u.check_version('0.5')
|
||||
unit.TestUnit().check_modules('python')
|
||||
|
||||
def pids_for_process(self, process=None):
|
||||
if process is None:
|
||||
|
||||
20
test/unit.py
20
test/unit.py
@@ -21,10 +21,6 @@ class TestUnit(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
self._stop()
|
||||
|
||||
if '--log' in sys.argv:
|
||||
with open(self.testdir + '/unit.log', 'r') as f:
|
||||
print(f.read())
|
||||
|
||||
if '--leave' not in sys.argv:
|
||||
shutil.rmtree(self.testdir)
|
||||
|
||||
@@ -34,7 +30,7 @@ class TestUnit(unittest.TestCase):
|
||||
for i in range(50):
|
||||
with open(self.testdir + '/unit.log', 'r') as f:
|
||||
log = f.read()
|
||||
m = re.search('controller started', log, re.M | re.S)
|
||||
m = re.search('controller started', log)
|
||||
|
||||
if m is None:
|
||||
time.sleep(0.1)
|
||||
@@ -42,11 +38,12 @@ class TestUnit(unittest.TestCase):
|
||||
break
|
||||
|
||||
if m is None:
|
||||
self._stop()
|
||||
exit("Unit is writing log too long")
|
||||
|
||||
missed_module = ''
|
||||
for module in modules:
|
||||
m = re.search('module: ' + module, log, re.M | re.S)
|
||||
m = re.search('module: ' + module, log)
|
||||
if m is None:
|
||||
missed_module = module
|
||||
break
|
||||
@@ -57,17 +54,6 @@ class TestUnit(unittest.TestCase):
|
||||
if missed_module:
|
||||
raise unittest.SkipTest('Unit has no ' + missed_module + ' module')
|
||||
|
||||
def check_version(self, version):
|
||||
with open(self.pardir + '/src/nxt_main.h' , 'r') as f:
|
||||
m = re.search('NXT_VERSION\s+"(\d+\.\d+)"', f.read(), re.M | re.S)
|
||||
|
||||
current = m.group(1).split('.')
|
||||
need = version.split('.')
|
||||
|
||||
for i in range(len(need)):
|
||||
if need[i] > current[i]:
|
||||
raise unittest.SkipTest('Unit too old')
|
||||
|
||||
def _run(self):
|
||||
self.testdir = tempfile.mkdtemp(prefix='unit-test-')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user