Tests: reworked python tests with application.

This commit is contained in:
Andrey Zelenkov
2018-02-20 20:34:41 +03:00
parent babf67712e
commit 09f2009df5
12 changed files with 104 additions and 191 deletions

View File

@@ -3,46 +3,20 @@ import time
import unittest
import unit
class TestUnitPythonAtExit(unit.TestUnitControl):
class TestUnitPythonAtExit(unit.TestUnitApplicationPython):
def setUpClass():
unit.TestUnit().check_modules('python')
def test_python_atexit(self):
code, name = """
import atexit
self.load('atexit')
def create_file():
open('%s', 'w')
atexit.register(create_file)
def application(env, start_response):
start_response('200', [('Content-Length', '0')])
return []
""" % (self.testdir + '/atexit'), 'py_app'
self.python_application(name, code)
self.conf({
"listeners": {
"*:7080": {
"application": "app"
}
},
"applications": {
"app": {
"type": "python",
"processes": { "spare": 0 },
"path": self.testdir + '/' + name,
"module": "wsgi"
}
}
self.get(headers={
'Host': 'localhost',
'Test-Dir': self.testdir,
'Connection': 'close'
})
self.get()
self.conf({
"listeners": {},
"applications": {}
@@ -53,6 +27,5 @@ def application(env, start_response):
self.assertEqual(os.path.exists(self.testdir + '/atexit'), True,
'python atexit')
if __name__ == '__main__':
unittest.main()