test_asgi_lifespan.py (1632:f9589b78bbb3) test_asgi_lifespan.py (1635:97afbb6c5a15)
1import os
1import os
2import pytest
3from distutils.version import LooseVersion
4
2from distutils.version import LooseVersion
3
4import pytest
5
6from conftest import option
7from conftest import public_dir
5from unit.applications.lang.python import TestApplicationPython
8from unit.applications.lang.python import TestApplicationPython
6from conftest import option, public_dir
7
8
9class TestASGILifespan(TestApplicationPython):
10 prerequisites = {
11 'modules': {'python': lambda v: LooseVersion(v) >= LooseVersion('3.5')}
12 }
13 load_module = 'asgi'
14
15 def test_asgi_lifespan(self):
16 self.load('lifespan/empty')
17
18 startup_path = option.test_dir + '/python/lifespan/empty/startup'
19 shutdown_path = option.test_dir + '/python/lifespan/empty/shutdown'
20 version_path = option.test_dir + '/python/lifespan/empty/version'
21
9
10
11class TestASGILifespan(TestApplicationPython):
12 prerequisites = {
13 'modules': {'python': lambda v: LooseVersion(v) >= LooseVersion('3.5')}
14 }
15 load_module = 'asgi'
16
17 def test_asgi_lifespan(self):
18 self.load('lifespan/empty')
19
20 startup_path = option.test_dir + '/python/lifespan/empty/startup'
21 shutdown_path = option.test_dir + '/python/lifespan/empty/shutdown'
22 version_path = option.test_dir + '/python/lifespan/empty/version'
23
24 os.chmod(option.test_dir + '/python/lifespan/empty', 0o777)
25
22 open(startup_path, 'a').close()
26 open(startup_path, 'a').close()
27 os.chmod(startup_path, 0o777)
28
23 open(shutdown_path, 'a').close()
29 open(shutdown_path, 'a').close()
30 os.chmod(shutdown_path, 0o777)
31
24 open(version_path, 'a').close()
32 open(version_path, 'a').close()
33 os.chmod(version_path, 0o777)
25
34
26 public_dir(option.test_dir + '/python/lifespan/empty')
27
28 assert self.get()['status'] == 204
29
30 self.stop()
31
32 is_startup = os.path.isfile(startup_path)
33 is_shutdown = os.path.isfile(shutdown_path)
34
35 if is_startup:

--- 38 unchanged lines hidden ---
35 assert self.get()['status'] == 204
36
37 self.stop()
38
39 is_startup = os.path.isfile(startup_path)
40 is_shutdown = os.path.isfile(shutdown_path)
41
42 if is_startup:

--- 38 unchanged lines hidden ---