l.s.t.t.TestTimeout(TestCase) : class documentation

Part of lp.services.tests.test_timeout View In Hierarchy

No class docstring
Method test_timeout_succeeds After decorating a function 'with_timeout', as long as that function
Method test_timeout_overrun If the operation cannot be completed in the allotted time, a
Method test_timeout_with_failing_function Other exceptions are reported correctly to the caller.
Method test_timeout_with_cleanup Since we want to time out operations involving an external resource
Method test_timeout_with_string_cleanup The cleanup parameter can also be a string in which case it will be
Method test_invalid_string_without_method It's an error to use a string cleanup when the function isn't a
Method test_timeout_uses_default If the timeout parameter isn't provided, it will default to the
Method test_timeout_requires_value_when_no_default When there is no default timeout function, it's an error not to
Method test_set_default_timeout The set_default_timeout_function() takes a function that should
Method test_default_timeout default_timeout sets the default timeout if none is set.
Method test_reduced_timeout reduced_timeout caps the available timeout in various ways.
Method make_test_socket One common use case for timing out is when making an HTTP request
Method test_urlfetch_raises_requests_exceptions Normal requests exceptions are raised.
Method test_urlfetch_timeout_after_listen After the listen() is called, connections will hang until accept()
Method test_urlfetch_slow_server The function also times out if the server replies very slowly.
Method test_urlfetch_returns_the_content When the request succeeds, the result content is returned.
Method test_urlfetch_does_not_support_ftp_urls urlfetch() does not support ftp urls.
Method test_xmlrpc_transport Another use case for timeouts is communicating with external

Inherited from TestCase:

Method becomeDbUser Commit, then log into the database as dbuser.
Method __str__ The string representation of a test is its id.
Method useContext Use the supplied context in this test.
Method makeTemporaryDirectory Create a temporary directory, and return its path.
Method installKarmaRecorder Set up and return a KarmaRecorder.
Method assertProvides Assert 'obj' correctly provides 'interface'.
Method assertNotifies Assert that a callable performs a given notification.
Method assertNoNotification Assert that no notifications are generated by the callable.
Method assertSqlAttributeEqualsDate Fail unless the value of the attribute is equal to the date.
Method assertTextMatchesExpressionIgnoreWhitespace Undocumented
Method assertIsInstance Assert that an instance is an instance of assert_class.
Method assertIsNot Assert that expected is not the same object as observed.
Method assertContentEqual Assert that 'iter1' has the same content as 'iter2'.
Method assertRaisesWithContent Check if the given exception is raised with given content.
Method assertBetween Assert that 'variable' is strictly between two boundaries.
Method assertVectorEqual Apply assertEqual to all given pairs in one go.
Method expectedLog Expect a log to be written that matches the regex.
Method pushConfig Push some key-value pairs into a section of the config.
Method attachOopses Undocumented
Method attachLibrarianLog Include the logChunks from fixture in the test details.
Method setUp Undocumented
Method assertStatementCount Assert that the expected number of SQL statements occurred.
Method useTempDir Use a temporary directory for this test.
Method assertEmailHeadersEqual Assert that two email headers are equal.
Method assertStartsWith Undocumented
Method assertEndsWith Asserts that s ends with suffix.
Method checkPermissions Check if the used_permissions match expected_permissions.
Method assertEmailQueueLength Pop the email queue, assert its length, and return it.
Method _unfoldEmailHeader Unfold a multiline email header.
def test_timeout_succeeds(self):
After decorating a function 'with_timeout', as long as that function finishes before the supplied timeout, it should function normally.
def test_timeout_overrun(self):
If the operation cannot be completed in the allotted time, a TimeoutError is raised.
def test_timeout_with_failing_function(self):
Other exceptions are reported correctly to the caller.
def test_timeout_with_cleanup(self):
Since we want to time out operations involving an external resource (subprocess, remote site), we need a way to clean-up these resources once they time out. To this end, the with_timeout decorator accepts a callable parameter (named 'cleanup') that will be invoked if the operation times out.
def test_timeout_with_string_cleanup(self):
The cleanup parameter can also be a string in which case it will be interpreted as the name of an instance method.
def test_invalid_string_without_method(self):
It's an error to use a string cleanup when the function isn't a method.
def test_timeout_uses_default(self):
If the timeout parameter isn't provided, it will default to the value returned by the function installed as "default_timeout_function". A function is used because it's useful for the timeout value to be determined dynamically. For example, if you want to limit the overall processing to 30s and you already did 14s, you want that timeout to be 16s.

By default, there is no default_timeout_function.

def test_timeout_requires_value_when_no_default(self):
When there is no default timeout function, it's an error not to provide a default timeout argument.
def test_set_default_timeout(self):
The set_default_timeout_function() takes a function that should return the number of seconds to wait.
def test_default_timeout(self):
default_timeout sets the default timeout if none is set.
def test_reduced_timeout(self):
reduced_timeout caps the available timeout in various ways.
def make_test_socket(self):
One common use case for timing out is when making an HTTP request to an external site to fetch content. To this end, the timeout module has a urlfetch() function that retrieves a URL in such a way as to timeout using the default timeout function and clean-up the socket properly.
def test_urlfetch_raises_requests_exceptions(self):
Normal requests exceptions are raised.
def test_urlfetch_timeout_after_listen(self):
After the listen() is called, connections will hang until accept() is called, so a TimeoutError will be raised.
def test_urlfetch_slow_server(self):
The function also times out if the server replies very slowly. (Do the server part in a separate thread.)
def test_urlfetch_returns_the_content(self):
When the request succeeds, the result content is returned.
def test_urlfetch_does_not_support_ftp_urls(self):
urlfetch() does not support ftp urls.
def test_xmlrpc_transport(self):
Another use case for timeouts is communicating with external systems using XMLRPC. In order to allow timeouts using XMLRPC we provide a transport that is timeout-aware. The Transport is used for XMLRPC over HTTP.
API Documentation for Launchpad, generated by pydoctor at 2018-05-27 00:00:04.