diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-17 15:52:01 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-17 15:52:01 +0300 |
commit | a949c2f08818bb9a8c8e54ed35e2a4a95a07acd3 (patch) | |
tree | 736d44e5f2ec188c47312d8cd9e2310312f00bff /test/test_python_atexit.py | |
parent | 37a713c217d132df89dc3726c33e4e96456d4433 (diff) | |
download | unit-a949c2f08818bb9a8c8e54ed35e2a4a95a07acd3.tar.gz unit-a949c2f08818bb9a8c8e54ed35e2a4a95a07acd3.tar.bz2 |
Tests: using LF line ending for test files.
Diffstat (limited to 'test/test_python_atexit.py')
-rw-r--r-- | test/test_python_atexit.py | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/test/test_python_atexit.py b/test/test_python_atexit.py index 28b6f67b..be45d113 100644 --- a/test/test_python_atexit.py +++ b/test/test_python_atexit.py @@ -1,65 +1,65 @@ -import os
-import time
-import unittest
-import unit
-
-class TestUnitApplication(unit.TestUnitControl):
-
- def setUpClass():
- u = unit.TestUnit()
-
- u.check_modules('python')
- u.check_version('0.3')
-
- def test_python_application(self):
- code, name = """
-import atexit
-
-def create_file():
- open('%s', 'w')
-
-atexit.register(create_file)
-
-def application(env, start_response):
- start_response('200 OK', [('Content-Type','text/html')])
- return [b'body']
-
-""" % (self.testdir + '/atexit'), 'py_app'
-
- self.python_application(name, code)
-
- self.put('/', """
- {
- "listeners": {
- "*:7080": {
- "application": "app"
- }
- },
- "applications": {
- "app": {
- "type": "python",
- "workers": 1,
- "path": "%s",
- "module": "wsgi"
- }
- }
- }
- """ % (self.testdir + '/' + name))
-
- unit.TestUnitHTTP.get()
-
- self.put('/', """
- {
- "listeners": {},
- "applications": {}
- }
- """)
-
- time.sleep(0.2)
-
- self.assertEqual(os.path.exists(self.testdir + '/atexit'), True,
- 'python atexit')
-
-
-if __name__ == '__main__':
- unittest.main()
+import os +import time +import unittest +import unit + +class TestUnitApplication(unit.TestUnitControl): + + def setUpClass(): + u = unit.TestUnit() + + u.check_modules('python') + u.check_version('0.3') + + def test_python_application(self): + code, name = """ +import atexit + +def create_file(): + open('%s', 'w') + +atexit.register(create_file) + +def application(env, start_response): + start_response('200 OK', [('Content-Type','text/html')]) + return [b'body'] + +""" % (self.testdir + '/atexit'), 'py_app' + + self.python_application(name, code) + + self.put('/', """ + { + "listeners": { + "*:7080": { + "application": "app" + } + }, + "applications": { + "app": { + "type": "python", + "workers": 1, + "path": "%s", + "module": "wsgi" + } + } + } + """ % (self.testdir + '/' + name)) + + unit.TestUnitHTTP.get() + + self.put('/', """ + { + "listeners": {}, + "applications": {} + } + """) + + time.sleep(0.2) + + self.assertEqual(os.path.exists(self.testdir + '/atexit'), True, + 'python atexit') + + +if __name__ == '__main__': + unittest.main() |