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 test_override_timeout override_timeout temporarily overrides the default timeout.
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_no_proxy_by_default urlfetch does not use a proxy by default.
Method test_urlfetch_uses_proxies_if_requested urlfetch uses proxies if explicitly requested.
Method test_urlfetch_no_ca_certificates If ca_certificates_path is None, urlfetch uses bundled certs.
Method test_urlfetch_ca_certificates_if_configured urlfetch uses the configured ca_certificates_path if it is set.
Method test_urlfetch_does_not_support_ftp_urls_by_default urlfetch() does not support ftp urls by default.
Method test_urlfetch_supports_ftp_urls_if_allow_ftp urlfetch() supports ftp urls via a proxy if explicitly asked.
Method test_urlfetch_does_not_support_file_urls_by_default urlfetch() does not support file urls by default.
Method test_urlfetch_supports_file_urls_if_allow_file urlfetch() supports file urls if explicitly asked to do so.
Method test_urlfetch_writes_to_output_file If given an output_file, urlfetch writes to it.
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 test_override_timeout(self):
override_timeout temporarily overrides the default timeout.
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_no_proxy_by_default(self):
urlfetch does not use a proxy by default.
def test_urlfetch_uses_proxies_if_requested(self):
urlfetch uses proxies if explicitly requested.
def test_urlfetch_no_ca_certificates(self):
If ca_certificates_path is None, urlfetch uses bundled certs.
def test_urlfetch_ca_certificates_if_configured(self):
urlfetch uses the configured ca_certificates_path if it is set.
def test_urlfetch_does_not_support_ftp_urls_by_default(self):
urlfetch() does not support ftp urls by default.
def test_urlfetch_supports_ftp_urls_if_allow_ftp(self):
urlfetch() supports ftp urls via a proxy if explicitly asked.
def test_urlfetch_does_not_support_file_urls_by_default(self):
urlfetch() does not support file urls by default.
def test_urlfetch_supports_file_urls_if_allow_file(self):
urlfetch() supports file urls if explicitly asked to do so.
def test_urlfetch_writes_to_output_file(self):
If given an output_file, urlfetch writes to it.
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 2022-06-16 00:00:12.