summaryrefslogtreecommitdiffhomepage
path: root/test/test_asgi_lifespan.py
diff options
context:
space:
mode:
authorDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
committerDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
commitd76761901c4084bcdbc5a449e9bbb47d56b7093c (patch)
treeb4b7b4e3d588b73a2adcc0094cab466d9194c679 /test/test_asgi_lifespan.py
parentc43629880472bba8d389dfb0b7ae6d883b0ba499 (diff)
parent088117008c9e8f397a58cc8d8070ce047beff12f (diff)
downloadunit-1.32.0-1.tar.gz
unit-1.32.0-1.tar.bz2
Merge tag '1.32.0' into branches/packaging1.32.0-1
Unit 1.32.0 release.
Diffstat (limited to 'test/test_asgi_lifespan.py')
-rw-r--r--test/test_asgi_lifespan.py35
1 files changed, 15 insertions, 20 deletions
diff --git a/test/test_asgi_lifespan.py b/test/test_asgi_lifespan.py
index 499f523d..e09ea1cc 100644
--- a/test/test_asgi_lifespan.py
+++ b/test/test_asgi_lifespan.py
@@ -1,7 +1,8 @@
-import os
+from pathlib import Path
-from conftest import unit_stop
from packaging import version
+
+from conftest import unit_stop
from unit.applications.lang.python import ApplicationPython
from unit.option import option
@@ -14,32 +15,26 @@ client = ApplicationPython(load_module='asgi')
def assert_cookies(prefix):
for name in ['startup', 'shutdown']:
- path = f'{option.test_dir}/python/lifespan/empty/{prefix}{name}'
- exists = os.path.isfile(path)
- if exists:
- os.remove(path)
+ path = Path(f'{option.test_dir}/python/lifespan/empty/{prefix}{name}')
+ exists = path.is_file()
+ path.unlink(missing_ok=True)
assert not exists, name
- path = f'{option.test_dir}/python/lifespan/empty/{prefix}version'
+ path = Path(f'{option.test_dir}/python/lifespan/empty/{prefix}version')
+ versions = path.read_text(encoding='utf-8')
+ path.unlink()
- with open(path, 'r') as f:
- version = f.read()
-
- os.remove(path)
-
- assert version == '3.0 2.0', 'version'
+ assert versions == '3.0 2.0', 'versions'
def setup_cookies(prefix):
- base_dir = f'{option.test_dir}/python/lifespan/empty'
-
- os.chmod(base_dir, 0o777)
+ base_dir = Path(f'{option.test_dir}/python/lifespan/empty')
+ base_dir.chmod(0o777)
for name in ['startup', 'shutdown', 'version']:
- path = f'{option.test_dir}/python/lifespan/empty/{prefix}{name}'
- open(path, 'a').close()
- os.chmod(path, 0o777)
+ path = Path(f'{option.test_dir}/python/lifespan/empty/{prefix}{name}')
+ path.touch(0o777)
def test_asgi_lifespan():
@@ -59,7 +54,7 @@ def test_asgi_lifespan_targets():
assert 'success' in client.conf(
{
- "listeners": {"*:7080": {"pass": "routes"}},
+ "listeners": {"*:8080": {"pass": "routes"}},
"routes": [
{
"match": {"uri": "/1"},