cheroot.test.test_server module#

Tests for the HTTP server.

class cheroot.test.test_server._TestGateway(req)#

Bases: Gateway


Process the current request. Must be overridden in a subclass.


Disable garbage collection when this fixture is in use.

cheroot.test.test_server.many_open_sockets(request, resource_limit)#

Allocate a lot of file descriptors by opening dummy sockets.

cheroot.test.test_server.peercreds_enabled_server(http_server, unix_sock_file)#

Construct a test server with peercreds_enabled.


Set the resource limit two times bigger then requested.

cheroot.test.test_server.test_bind_addr_inet(http_server, ip_addr)#

Check that bound IP address is stored in server.

cheroot.test.test_server.test_bind_addr_unix(http_server, unix_sock_file)#

Check that bound UNIX socket address is stored in server.

cheroot.test.test_server.test_bind_addr_unix_abstract(http_server, unix_abstract_sock)#

Check that bound UNIX abstract socket address is stored in server.

cheroot.test.test_server.test_high_number_of_file_descriptors(native_server_client, resource_limit)#

Test the server does not crash with a high file-descriptor value.

This test shouldn’t cause a server crash when trying to access file-descriptor higher than 1024.

The earlier implementation used to rely on select() syscall that doesn’t support file descriptors with numbers higher than 1024.

cheroot.test.test_server.test_peercreds_unix_sock(http_request_timeout, peercreds_enabled_server)#

Check that PEERCRED lookup works when enabled.

cheroot.test.test_server.test_peercreds_unix_sock_with_lookup(http_request_timeout, peercreds_enabled_server)#

Check that PEERCRED resolution works when enabled.


Check that prepare() makes the server ready, and stop() clears it.

cheroot.test.test_server.test_reuse_port(http_server, ip_addr, mocker)#

Check that port initialized externally can be reused.


Check that assigning interrupt stops the server.


Check that stop() interrupts running of serve().


Check that stop() interrupts running of serve().

cheroot.test.test_server.test_threadpool_invalid_threadrange(minthreads, maxthreads, error)#

Test that a ThreadPool rejects invalid min/max values.

The ThreadPool should raise an error with the proper message when initialized with an invalid min+max number of threads.


Test for ThreadPool multi-start behavior.

Tests that when calling start() on a ThreadPool multiple times raises a RuntimeError

cheroot.test.test_server.test_threadpool_threadrange_set(minthreads, maxthreads, inited_maxthreads)#

Test setting the number of threads in a ThreadPool.

The ThreadPool should properly set the min+max number of the threads to use in the pool if those limits are valid.


Return an abstract UNIX socket address.


Yield a unix file socket.


Check that bound UNIX socket address is stored in server.