summaryrefslogtreecommitdiffhomepage
path: root/test/test_asgi_application.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2023-05-29 16:45:49 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2023-05-29 16:45:49 +0100
commit31ff94add9c4043a753683d9e8b68733c69aa1ac (patch)
tree1737c36a2641129a4de775c6058cc07b9cdca0f6 /test/test_asgi_application.py
parentf55818059c01ff9e61bee8107ed1389fe272a787 (diff)
downloadunit-31ff94add9c4043a753683d9e8b68733c69aa1ac.tar.gz
unit-31ff94add9c4043a753683d9e8b68733c69aa1ac.tar.bz2
Tests: more fixtures.
Common methods from applications/proto.py converted to the fixtures. sysctl check moved to the specific file where it is using. Some options moved to the constructor to have early access.
Diffstat (limited to 'test/test_asgi_application.py')
-rw-r--r--test/test_asgi_application.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/test/test_asgi_application.py b/test/test_asgi_application.py
index 10e72367..e2f74dd9 100644
--- a/test/test_asgi_application.py
+++ b/test/test_asgi_application.py
@@ -14,7 +14,7 @@ class TestASGIApplication(TestApplicationPython):
}
load_module = 'asgi'
- def test_asgi_application_variables(self):
+ def test_asgi_application_variables(self, date_to_sec_epoch, sec_epoch):
self.load('variables')
body = 'Test body string.'
@@ -40,9 +40,7 @@ custom-header: BLAH
date = headers.pop('Date')
assert date[-4:] == ' GMT', 'date header timezone'
- assert (
- abs(self.date_to_sec_epoch(date) - self.sec_epoch()) < 5
- ), 'date header'
+ assert abs(date_to_sec_epoch(date) - sec_epoch) < 5, 'date header'
assert headers == {
'Connection': 'close',
@@ -382,7 +380,7 @@ Connection: close
assert self.get()['status'] == 503, 'loading error'
- def test_asgi_application_threading(self):
+ def test_asgi_application_threading(self, wait_for_record):
"""wait_for_record() timeouts after 5s while every thread works at
least 3s. So without releasing GIL test should fail.
"""
@@ -393,7 +391,7 @@ Connection: close
self.get(no_recv=True)
assert (
- self.wait_for_record(r'\(5\) Thread: 100', wait=50) is not None
+ wait_for_record(r'\(5\) Thread: 100', wait=50) is not None
), 'last thread finished'
def test_asgi_application_threads(self):