mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 16:22:57 -07:00
Update cheroot-8.5.2
This commit is contained in:
parent
4ac151d7de
commit
182e5f553e
25 changed files with 2171 additions and 602 deletions
|
@ -1,12 +1,14 @@
|
|||
"""Extensions to unittest for web frameworks.
|
||||
|
||||
Use the WebCase.getPage method to request a page from your HTTP server.
|
||||
Use the :py:meth:`WebCase.getPage` method to request a page
|
||||
from your HTTP server.
|
||||
|
||||
Framework Integration
|
||||
=====================
|
||||
If you have control over your server process, you can handle errors
|
||||
in the server-side of the HTTP conversation a bit better. You must run
|
||||
both the client (your WebCase tests) and the server in the same process
|
||||
(but in separate threads, obviously).
|
||||
both the client (your :py:class:`WebCase` tests) and the server in the
|
||||
same process (but in separate threads, obviously).
|
||||
When an error occurs in the framework, call server_error. It will print
|
||||
the traceback to stdout, and keep any assertions you have from running
|
||||
(the assumption is that, if the server errors, the page output will not
|
||||
|
@ -122,7 +124,7 @@ class WebCase(unittest.TestCase):
|
|||
def _Conn(self):
|
||||
"""Return HTTPConnection or HTTPSConnection based on self.scheme.
|
||||
|
||||
* from http.client.
|
||||
* from :py:mod:`python:http.client`.
|
||||
"""
|
||||
cls_name = '{scheme}Connection'.format(scheme=self.scheme.upper())
|
||||
return getattr(http_client, cls_name)
|
||||
|
@ -157,7 +159,7 @@ class WebCase(unittest.TestCase):
|
|||
|
||||
@property
|
||||
def persistent(self):
|
||||
"""Presense of the persistent HTTP connection."""
|
||||
"""Presence of the persistent HTTP connection."""
|
||||
return hasattr(self.HTTP_CONN, '__class__')
|
||||
|
||||
@persistent.setter
|
||||
|
@ -176,7 +178,9 @@ class WebCase(unittest.TestCase):
|
|||
self, url, headers=None, method='GET', body=None,
|
||||
protocol=None, raise_subcls=(),
|
||||
):
|
||||
"""Open the url with debugging support. Return status, headers, body.
|
||||
"""Open the url with debugging support.
|
||||
|
||||
Return status, headers, body.
|
||||
|
||||
url should be the identifier passed to the server, typically a
|
||||
server-absolute path and query string (sent between method and
|
||||
|
@ -184,16 +188,16 @@ class WebCase(unittest.TestCase):
|
|||
enabled in the server.
|
||||
|
||||
If the application under test generates absolute URIs, be sure
|
||||
to wrap them first with strip_netloc::
|
||||
to wrap them first with :py:func:`strip_netloc`::
|
||||
|
||||
class MyAppWebCase(WebCase):
|
||||
def getPage(url, *args, **kwargs):
|
||||
super(MyAppWebCase, self).getPage(
|
||||
cheroot.test.webtest.strip_netloc(url),
|
||||
*args, **kwargs
|
||||
)
|
||||
>>> class MyAppWebCase(WebCase):
|
||||
... def getPage(url, *args, **kwargs):
|
||||
... super(MyAppWebCase, self).getPage(
|
||||
... cheroot.test.webtest.strip_netloc(url),
|
||||
... *args, **kwargs
|
||||
... )
|
||||
|
||||
`raise_subcls` is passed through to openURL.
|
||||
``raise_subcls`` is passed through to :py:func:`openURL`.
|
||||
"""
|
||||
ServerError.on = False
|
||||
|
||||
|
@ -247,7 +251,7 @@ class WebCase(unittest.TestCase):
|
|||
|
||||
console_height = 30
|
||||
|
||||
def _handlewebError(self, msg):
|
||||
def _handlewebError(self, msg): # noqa: C901 # FIXME
|
||||
print('')
|
||||
print(' ERROR: %s' % msg)
|
||||
|
||||
|
@ -487,7 +491,7 @@ def openURL(*args, **kwargs):
|
|||
"""
|
||||
Open a URL, retrying when it fails.
|
||||
|
||||
Specify `raise_subcls` (class or tuple of classes) to exclude
|
||||
Specify ``raise_subcls`` (class or tuple of classes) to exclude
|
||||
those socket.error subclasses from being suppressed and retried.
|
||||
"""
|
||||
raise_subcls = kwargs.pop('raise_subcls', ())
|
||||
|
@ -553,7 +557,7 @@ def strip_netloc(url):
|
|||
server-absolute portion.
|
||||
|
||||
Useful for wrapping an absolute-URI for which only the
|
||||
path is expected (such as in calls to getPage).
|
||||
path is expected (such as in calls to :py:meth:`WebCase.getPage`).
|
||||
|
||||
>>> strip_netloc('https://google.com/foo/bar?bing#baz')
|
||||
'/foo/bar?bing'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue