This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new e5ca5b10d improve some alluratest type hints
e5ca5b10d is described below
commit e5ca5b10d25ee10f80020864f32ac774bdc478df
Author: Dillon Walls <[email protected]>
AuthorDate: Wed Nov 8 14:37:31 2023 +0000
improve some alluratest type hints
---
AlluraTest/alluratest/validation.py | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/AlluraTest/alluratest/validation.py
b/AlluraTest/alluratest/validation.py
index 3102f3e6a..c8c246aff 100644
--- a/AlluraTest/alluratest/validation.py
+++ b/AlluraTest/alluratest/validation.py
@@ -33,7 +33,7 @@ import pkg_resources
import six
import webtest
-from webtest import TestApp
+from webtest import TestApp, TestResponse
from ming.utils import LazyProperty
import requests
@@ -214,7 +214,7 @@ def validate_page(html_or_response):
class AntiSpamTestApp(TestApp):
- def post(self, *args, **kwargs):
+ def post(self, *args, **kwargs) -> TestResponse:
antispam = utils.AntiSpam()
if kwargs.pop('antispam', False):
params = {
@@ -274,7 +274,7 @@ class PostParamCheckingTestApp(AntiSpamTestApp):
'%s key %s has value %s of type %s, not str. ' %
(method, k, v, type(v)))
- def get(self, *args, **kwargs):
+ def get(self, *args, **kwargs) -> TestResponse:
params = None
if 'params' in kwargs:
params = kwargs['params']
@@ -283,7 +283,7 @@ class PostParamCheckingTestApp(AntiSpamTestApp):
self._validate_params(params, 'get')
return super().get(*args, **kwargs)
- def post(self, *args, **kwargs):
+ def post(self, *args, **kwargs) -> TestResponse:
params = None
if 'params' in kwargs:
params = kwargs['params']
@@ -333,37 +333,28 @@ class ValidatingTestApp(PostParamCheckingTestApp):
params[k] = kw.pop(k, False)
return params, kw
- def get(self, *args, **kw):
- '''
- :rtype: webtest.app.TestResponse
- '''
+ def get(self, *args, **kw) -> TestResponse:
val_params, kw = self._get_validation_params(kw)
resp = super().get(*args, **kw)
if not self.validate_skip and not val_params['validate_skip']:
self._validate(resp, 'get', val_params)
return resp
- def post(self, *args, **kw):
- '''
- :rtype: webtest.app.TestResponse
- '''
+ def post(self, *args, **kw) -> TestResponse:
val_params, kw = self._get_validation_params(kw)
resp = super().post(*args, **kw)
if not self.validate_skip and not val_params['validate_skip']:
self._validate(resp, 'post', val_params)
return resp
- def delete(self, *args, **kw):
- '''
- :rtype: webtest.app.TestResponse
- '''
+ def delete(self, *args, **kw) -> TestResponse:
val_params, kw = self._get_validation_params(kw)
resp = super().delete(*args, **kw)
if not self.validate_skip and not val_params['validate_skip']:
self._validate(resp, 'delete', val_params)
return resp
- def do_request(self, *args, **kwargs):
+ def do_request(self, *args, **kwargs) -> TestResponse:
# middleware should do this already, but be sure that no global
c/config/request etc remains between tests
resp = super().do_request(*args, **kwargs)
tgGlobalsRegistry = resp.request.environ['paste.registry']