cherrypy.test package

Submodules

cherrypy.test.benchmark module

cherrypy.test.checkerdemo module

Demonstration app for cherrypy.checker.

This application is intentionally broken and badly designed. To demonstrate the output of the CherryPy Checker, simply execute this module.

class cherrypy.test.checkerdemo.Root[source]

Bases: object

cherrypy.test.helper module

A library of helper functions for the CherryPy test suite.

class cherrypy.test.helper.CPProcess(wait=False, daemonize=False, ssl=False, socket_host=None, socket_port=None)[source]

Bases: object

access_log = '/home/docs/checkouts/readthedocs.org/user_builds/cherrypy/envs/latest/lib/python3.5/site-packages/cherrypy/test/test.access.log'
config_file = '/home/docs/checkouts/readthedocs.org/user_builds/cherrypy/envs/latest/lib/python3.5/site-packages/cherrypy/test/test.conf'
config_template = "[global]\nserver.socket_host: '%(host)s'\nserver.socket_port: %(port)s\nchecker.on: False\nlog.screen: False\nlog.error_file: r'%(error_log)s'\nlog.access_file: r'%(access_log)s'\n%(ssl)s\n%(extra)s\n"
error_log = '/home/docs/checkouts/readthedocs.org/user_builds/cherrypy/envs/latest/lib/python3.5/site-packages/cherrypy/test/test.error.log'
get_pid()[source]
join()[source]

Wait for the process to exit.

pid_file = '/home/docs/checkouts/readthedocs.org/user_builds/cherrypy/envs/latest/lib/python3.5/site-packages/cherrypy/test/test.pid'
start(imports=None)[source]

Start cherryd in a subprocess.

write_conf(extra='')[source]
class cherrypy.test.helper.CPWebCase(methodName='runTest')[source]

Bases: cheroot.test.webtest.WebCase

assertEqualDates(dt1, dt2, seconds=None)[source]

Assert abs(dt1 - dt2) is within Y seconds.

assertErrorPage(status, message=None, pattern='')[source]

Compare the response body with a built in error page.

The function will optionally look for the regexp pattern, within the exception embedded in the error page.

available_servers = {'native': <class 'cherrypy.test.helper.NativeServerSupervisor'>, 'modwsgi': <function get_modwsgi_supervisor>, 'modfastcgi': <function get_modfastcgi_supervisor>, 'cpmodpy': <function get_cpmodpy_supervisor>, 'wsgi_u': <function get_wsgi_u_supervisor>, 'modfcgid': <function get_modfcgid_supervisor>, 'wsgi': <class 'cherrypy.test.helper.LocalWSGISupervisor'>, 'modpygw': <function get_modpygw_supervisor>}
base()[source]
date_tolerance = 2
default_server = 'wsgi'
do_gc_test = False
exit()[source]
getPage(url, headers=None, method='GET', body=None, protocol=None, raise_subcls=None)[source]

Open the url. Return status, headers, body.

raise_subcls must be a tuple with the exceptions classes or a single exception class that are not going to be considered a socket.error regardless that they were are subclass of a socket.error and therefore not considered for a connection retry.

prefix()[source]
scheme = 'http'
script_name = ''
classmethod setup_class()[source]
skip(msg='skipped ')[source]
classmethod teardown_class()[source]
test_gc()[source]
class cherrypy.test.helper.LocalSupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.Supervisor

Base class for modeling/controlling servers which run in the same process.

When the server side runs in a different process, start/stop can dump all state between each test module easily. When the server side runs in the same process as the client, however, we have to do a bit more work to ensure config and mounted apps are reset between tests.

start(modulename=None)[source]

Load and start the HTTP server.

stop()[source]
sync_apps()[source]

Tell the server about any apps which the setup functions mounted.

using_apache = False
using_wsgi = False
class cherrypy.test.helper.LocalWSGISupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.LocalSupervisor

Server supervisor for the builtin WSGI server.

get_app(app=None)[source]

Obtain a new (decorated) WSGI app to hook into the origin server.

httpserver_class = 'cherrypy._cpwsgi_server.CPWSGIServer'
sync_apps()[source]

Hook a new WSGI app into the origin server.

using_apache = False
using_wsgi = True
class cherrypy.test.helper.NativeServerSupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.LocalSupervisor

Server supervisor for the builtin HTTP server.

httpserver_class = 'cherrypy._cpnative_server.CPHTTPServer'
using_apache = False
using_wsgi = False
class cherrypy.test.helper.Supervisor(**kwargs)[source]

Bases: object

Base class for modeling and controlling servers during testing.

cherrypy.test.helper.get_cpmodpy_supervisor(**options)[source]
cherrypy.test.helper.get_modfastcgi_supervisor(**options)[source]
cherrypy.test.helper.get_modfcgid_supervisor(**options)[source]
cherrypy.test.helper.get_modpygw_supervisor(**options)[source]
cherrypy.test.helper.get_modwsgi_supervisor(**options)[source]
cherrypy.test.helper.get_wsgi_u_supervisor(**options)[source]
cherrypy.test.helper.log_to_stderr(msg, level)[source]
cherrypy.test.helper.setup_client()[source]

Set up the WebCase classes to match the server’s socket settings.

cherrypy.test.logtest module

logtest, a unittest.TestCase helper for testing log output.

class cherrypy.test.logtest.LogCase[source]

Bases: object

unittest.TestCase mixin for testing log messages.

logfile: a filename for the desired log. Yes, I know modes are evil,
but it makes the test functions so much cleaner to set this once.
lastmarker: the last marker in the log. This can be used to search for
messages since the last marker.
markerPrefix: a string with which to prefix log markers. This should be
unique enough from normal log output to use for marker identification.
assertInLog(line, marker=None)[source]

Fail if the given (partial) line is not in the log.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn’t been marked (using self.markLog), the entire log will be searched.

assertLog(sliceargs, lines, marker=None)[source]

Fail if log.readlines()[sliceargs] is not contained in ‘lines’.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn’t been marked (using self.markLog), the entire log will be searched.

assertNotInLog(line, marker=None)[source]

Fail if the given (partial) line is in the log.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn’t been marked (using self.markLog), the entire log will be searched.

assertValidUUIDv4(marker=None)[source]

Fail if the given UUIDv4 is not valid.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn’t been marked (using self.markLog), the entire log will be searched.

emptyLog()[source]

Overwrite self.logfile with 0 bytes.

exit()[source]
lastmarker = None
logfile = None
markLog(key=None)[source]

Insert a marker line into the log and set self.lastmarker.

markerPrefix = b'test suite marker: '
cherrypy.test.logtest.getchar()[source]

cherrypy.test.modfastcgi module

Wrapper for mod_fastcgi, for use as a CherryPy HTTP server when testing.

To autostart fastcgi, the “apache” executable or script must be on your system path, or you must override the global APACHE_PATH. On some platforms, “apache” may be called “apachectl”, “apache2ctl”, or “httpd”–create a symlink to them if needed.

You’ll also need the WSGIServer from flup.servers. See http://projects.amor.org/misc/wiki/ModPythonGateway

KNOWN BUGS

  1. Apache processes Range headers automatically; CherryPy’s truncated
    output is then truncated again by Apache. See test_core.testRanges. This was worked around in http://www.cherrypy.org/changeset/1319.
  2. Apache does not allow custom HTTP methods like CONNECT as per the spec.
    See test_core.testHTTPMethods.
  3. Max request header and body settings do not work with Apache.
  4. Apache replaces status “reason phrases” automatically. For example,
    CherryPy may set “304 Not modified” but Apache will write out “304 Not Modified” (capital “M”).
  5. Apache does not allow custom error codes as per the spec.
  6. Apache (or perhaps modpython, or modpython_gateway) unquotes %xx in the
    Request-URI too early.
  7. mod_python will not read request bodies which use the “chunked”
    transfer-coding (it passes REQUEST_CHUNKED_ERROR to ap_setup_client_block instead of REQUEST_CHUNKED_DECHUNK, see Apache2’s http_protocol.c and mod_python’s requestobject.c).
  8. Apache will output a “Content-Length: 0” response header even if there’s
    no response entity body. This isn’t really a bug; it just differs from the CherryPy default.
class cherrypy.test.modfastcgi.ModFCGISupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.LocalWSGISupervisor

httpserver_class = 'cherrypy.process.servers.FlupFCGIServer'
start(modulename)[source]
start_apache()[source]
stop()[source]

Gracefully shutdown a server that is serving forever.

sync_apps()[source]
template = '\n# Apache2 server conf file for testing CherryPy with mod_fastcgi.\n# fumanchu: I had to hard-code paths due to crazy Debian layouts :(\nServerRoot /usr/lib/apache2\nUser #1000\nErrorLog %(root)s/mod_fastcgi.error.log\n\nDocumentRoot "%(root)s"\nServerName 127.0.0.1\nListen %(port)s\nLoadModule fastcgi_module modules/mod_fastcgi.so\nLoadModule rewrite_module modules/mod_rewrite.so\n\nOptions +ExecCGI\nSetHandler fastcgi-script\nRewriteEngine On\nRewriteRule ^(.*)$ /fastcgi.pyc [L]\nFastCgiExternalServer "%(server)s" -host 127.0.0.1:4000\n'
using_apache = True
using_wsgi = True
cherrypy.test.modfastcgi.erase_script_name(environ, start_response)[source]
cherrypy.test.modfastcgi.read_process(cmd, args='')[source]

cherrypy.test.modfcgid module

Wrapper for mod_fcgid, for use as a CherryPy HTTP server when testing.

To autostart fcgid, the “apache” executable or script must be on your system path, or you must override the global APACHE_PATH. On some platforms, “apache” may be called “apachectl”, “apache2ctl”, or “httpd”–create a symlink to them if needed.

You’ll also need the WSGIServer from flup.servers. See http://projects.amor.org/misc/wiki/ModPythonGateway

KNOWN BUGS

  1. Apache processes Range headers automatically; CherryPy’s truncated
    output is then truncated again by Apache. See test_core.testRanges. This was worked around in http://www.cherrypy.org/changeset/1319.
  2. Apache does not allow custom HTTP methods like CONNECT as per the spec.
    See test_core.testHTTPMethods.
  3. Max request header and body settings do not work with Apache.
  4. Apache replaces status “reason phrases” automatically. For example,
    CherryPy may set “304 Not modified” but Apache will write out “304 Not Modified” (capital “M”).
  5. Apache does not allow custom error codes as per the spec.
  6. Apache (or perhaps modpython, or modpython_gateway) unquotes %xx in the
    Request-URI too early.
  7. mod_python will not read request bodies which use the “chunked”
    transfer-coding (it passes REQUEST_CHUNKED_ERROR to ap_setup_client_block instead of REQUEST_CHUNKED_DECHUNK, see Apache2’s http_protocol.c and mod_python’s requestobject.c).
  8. Apache will output a “Content-Length: 0” response header even if there’s
    no response entity body. This isn’t really a bug; it just differs from the CherryPy default.
class cherrypy.test.modfcgid.ModFCGISupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.LocalSupervisor

start(modulename)[source]
start_apache()[source]
stop()[source]

Gracefully shutdown a server that is serving forever.

sync_apps()[source]
template = '\n# Apache2 server conf file for testing CherryPy with mod_fcgid.\n\nDocumentRoot "%(root)s"\nServerName 127.0.0.1\nListen %(port)s\nLoadModule fastcgi_module modules/mod_fastcgi.dll\nLoadModule rewrite_module modules/mod_rewrite.so\n\nOptions ExecCGI\nSetHandler fastcgi-script\nRewriteEngine On\nRewriteRule ^(.*)$ /fastcgi.pyc [L]\nFastCgiExternalServer "%(server)s" -host 127.0.0.1:4000\n'
using_apache = True
using_wsgi = True
cherrypy.test.modfcgid.read_process(cmd, args='')[source]

cherrypy.test.modpy module

Wrapper for mod_python, for use as a CherryPy HTTP server when testing.

To autostart modpython, the “apache” executable or script must be on your system path, or you must override the global APACHE_PATH. On some platforms, “apache” may be called “apachectl” or “apache2ctl”– create a symlink to them if needed.

If you wish to test the WSGI interface instead of our _cpmodpy interface, you also need the ‘modpython_gateway’ module at: http://projects.amor.org/misc/wiki/ModPythonGateway

KNOWN BUGS

  1. Apache processes Range headers automatically; CherryPy’s truncated
    output is then truncated again by Apache. See test_core.testRanges. This was worked around in http://www.cherrypy.org/changeset/1319.
  2. Apache does not allow custom HTTP methods like CONNECT as per the spec.
    See test_core.testHTTPMethods.
  3. Max request header and body settings do not work with Apache.
  4. Apache replaces status “reason phrases” automatically. For example,
    CherryPy may set “304 Not modified” but Apache will write out “304 Not Modified” (capital “M”).
  5. Apache does not allow custom error codes as per the spec.
  6. Apache (or perhaps modpython, or modpython_gateway) unquotes %xx in the
    Request-URI too early.
  7. mod_python will not read request bodies which use the “chunked”
    transfer-coding (it passes REQUEST_CHUNKED_ERROR to ap_setup_client_block instead of REQUEST_CHUNKED_DECHUNK, see Apache2’s http_protocol.c and mod_python’s requestobject.c).
  8. Apache will output a “Content-Length: 0” response header even if there’s
    no response entity body. This isn’t really a bug; it just differs from the CherryPy default.
class cherrypy.test.modpy.ModPythonSupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.Supervisor

start(modulename)[source]
stop()[source]

Gracefully shutdown a server that is serving forever.

template = None
using_apache = True
using_wsgi = False
cherrypy.test.modpy.cpmodpysetup(req)[source]
cherrypy.test.modpy.read_process(cmd, args='')[source]
cherrypy.test.modpy.wsgisetup(req)[source]

cherrypy.test.modwsgi module

Wrapper for mod_wsgi, for use as a CherryPy HTTP server.

To autostart modwsgi, the “apache” executable or script must be on your system path, or you must override the global APACHE_PATH. On some platforms, “apache” may be called “apachectl” or “apache2ctl”– create a symlink to them if needed.

KNOWN BUGS

##1. Apache processes Range headers automatically; CherryPy’s truncated ## output is then truncated again by Apache. See test_core.testRanges. ## This was worked around in http://www.cherrypy.org/changeset/1319. 2. Apache does not allow custom HTTP methods like CONNECT as per the spec.

See test_core.testHTTPMethods.

3. Max request header and body settings do not work with Apache. ##4. Apache replaces status “reason phrases” automatically. For example, ## CherryPy may set “304 Not modified” but Apache will write out ## “304 Not Modified” (capital “M”). ##5. Apache does not allow custom error codes as per the spec. ##6. Apache (or perhaps modpython, or modpython_gateway) unquotes %xx in the ## Request-URI too early. 7. mod_wsgi will not read request bodies which use the “chunked”

transfer-coding (it passes REQUEST_CHUNKED_ERROR to ap_setup_client_block instead of REQUEST_CHUNKED_DECHUNK, see Apache2’s http_protocol.c and mod_python’s requestobject.c).
  1. When responding with 204 No Content, mod_wsgi adds a Content-Length
    header for you.
  2. When an error is raised, mod_wsgi has no facility for printing a
    traceback as the response content (it’s sent to the Apache log instead).
  3. Startup and shutdown of Apache when running mod_wsgi seems slow.
class cherrypy.test.modwsgi.ModWSGISupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.Supervisor

Server Controller for ModWSGI and CherryPy.

start(modulename)[source]
stop()[source]

Gracefully shutdown a server that is serving forever.

template = '\n# Apache2 server conf file for testing CherryPy with modpython_gateway.\n\nServerName 127.0.0.1\nDocumentRoot "/"\nListen %(port)s\n\nAllowEncodedSlashes On\nLoadModule rewrite_module modules/mod_rewrite.so\nRewriteEngine on\nRewriteMap escaping int:escape\n\nLoadModule log_config_module modules/mod_log_config.so\nLogFormat "%%h %%l %%u %%t \\"%%r\\" %%>s %%b \\"%%{Referer}i\\" \\"%%{User-agent}i\\"" combined\nCustomLog "%(curdir)s/apache.access.log" combined\nErrorLog "%(curdir)s/apache.error.log"\nLogLevel debug\n\nLoadModule wsgi_module modules/mod_wsgi.so\nLoadModule env_module modules/mod_env.so\n\nWSGIScriptAlias / "%(curdir)s/modwsgi.py"\nSetEnv testmod %(testmod)s\n'
using_apache = True
using_wsgi = True
cherrypy.test.modwsgi.application(environ, start_response)[source]
cherrypy.test.modwsgi.read_process(cmd, args='')[source]

cherrypy.test.sessiondemo module

A session demonstration app.

class cherrypy.test.sessiondemo.Root[source]

Bases: object

expire()[source]
index()[source]
page()[source]
regen()[source]

cherrypy.test.test_auth_basic module

class cherrypy.test.test_auth_basic.BasicAuthTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testBasic()[source]
testBasic2()[source]
testPublic()[source]

cherrypy.test.test_auth_digest module

class cherrypy.test.test_auth_digest.DigestAuthTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testDigest()[source]
testPublic()[source]

cherrypy.test.test_bus module

class cherrypy.test.test_bus.BusMethodTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

assertLog(entries)[source]
get_listener(channel, index)[source]
log(bus)[source]
test_block()[source]
test_exit()[source]
test_graceful()[source]
test_log()[source]
test_start()[source]
test_start_with_callback()[source]
test_stop()[source]
test_wait()[source]
class cherrypy.test.test_bus.PublishSubscribeTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

get_listener(channel, index)[source]
test_builtin_channels()[source]
test_custom_channels()[source]
test_listener_errors()[source]

cherrypy.test.test_caching module

class cherrypy.test.test_caching.CacheTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testCaching()[source]
testExpiresTool()[source]
testGzipStaticCache()[source]

Test that cache and gzip tools play well together when both enabled.

Ref GitHub issue #1190.

testLastModified()[source]
testVaryHeader()[source]
test_antistampede()[source]
test_cache_control()[source]

cherrypy.test.test_compat module

Test Python 2/3 compatibility module.

class cherrypy.test.test_compat.EscapeTester(methodName='runTest')[source]

Bases: unittest.case.TestCase

Class to test escape_html function from _cpcompat.

test_escape_quote()[source]

test_escape_quote - Verify the output for &<>”’ chars.

class cherrypy.test.test_compat.StringTester(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for string conversion.

test_ntob_non_native()[source]

ntob should raise an Exception on unicode.

(Python 2 only)

See #1132 for discussion.

cherrypy.test.test_config module

Tests for the CherryPy configuration system.

class cherrypy.test.test_config.CallablesInConfigTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

static setup_server()
test_call_with_kwargs()[source]
test_call_with_literal_dict()[source]
class cherrypy.test.test_config.ConfigTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
testConfig()[source]
testCustomNamespaces()[source]
testHandlerToolConfigOverride()[source]
testRespNamespaces()[source]
testUnrepr()[source]
test_request_body_namespace()[source]
cherrypy.test.test_config.StringIOFromNative(x)[source]
class cherrypy.test.test_config.VariableSubstitutionTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

static setup_server()
test_config()[source]
cherrypy.test.test_config.setup_server()[source]

cherrypy.test.test_config_server module

Tests for the CherryPy configuration system.

class cherrypy.test.test_config_server.ServerConfigTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

PORT = 9876
static setup_server()[source]
testAdditionalServers()[source]
testBasicConfig()[source]
testMaxRequestSize()[source]
testMaxRequestSizePerHandler()[source]

cherrypy.test.test_conn module

Tests for TCP connection handling, including proper and timely close.

class cherrypy.test.test_conn.BadRequestTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_No_CRLF()[source]
class cherrypy.test.test_conn.ConnectionCloseTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_HTTP10_KeepAlive()[source]
test_HTTP11()[source]
test_Streaming_no_len()[source]
test_Streaming_with_len()[source]
class cherrypy.test.test_conn.ConnectionTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_598()[source]
test_Chunked_Encoding()[source]
test_Content_Length_in()[source]
test_Content_Length_out_postheaders()[source]
test_Content_Length_out_preheaders()[source]
test_No_Message_Body()[source]
test_readall_or_close()[source]
class cherrypy.test.test_conn.LimitedRequestQueueTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_queue_full()[source]
class cherrypy.test.test_conn.PipelineTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_100_Continue()[source]
test_HTTP11_Timeout()[source]
test_HTTP11_Timeout_after_request()[source]
test_HTTP11_pipelining()[source]
cherrypy.test.test_conn.setup_server()[source]
cherrypy.test.test_conn.setup_upload_server()[source]
cherrypy.test.test_conn.socket_reset_errors = [104, 'Remote end closed connection without response']

reset error numbers available on this platform

cherrypy.test.test_core module

Basic tests for the CherryPy core: request handling.

class cherrypy.test.test_core.CoreRequestHandlingTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
skip_if_bad_cookies()[source]

cookies module fails to reject invalid cookies https://github.com/cherrypy/cherrypy/issues/1405

testCookies()[source]
testDefaultContentType()[source]
testFavicon()[source]
testFlatten()[source]
testRanges()[source]
testRedirect()[source]
testSlashes()[source]
testStatus()[source]
test_InternalRedirect()[source]
test_cherrypy_url()[source]
test_expose_decorator()[source]
test_multiple_headers()[source]
test_on_end_resource_status()[source]
test_redirect_with_unicode()[source]

A redirect to a URL with Unicode should return a Location header containing that Unicode URL.

test_redirect_with_xss()[source]

A redirect to a URL with HTML injected should result in page contents escaped.

class cherrypy.test.test_core.ErrorTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_contextmanager()[source]
test_start_response_error()[source]
class cherrypy.test.test_core.TestBinding[source]

Bases: object

test_bind_ephemeral_port()[source]

A server configured to bind to port 0 will bind to an ephemeral port and indicate that port number on startup.

cherrypy.test.test_dynamicobjectmapping module

class cherrypy.test.test_dynamicobjectmapping.DynamicObjectMappingTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
testMethodDispatch()[source]
testObjectMapping()[source]
testVpathDispatch()[source]
cherrypy.test.test_dynamicobjectmapping.setup_server()[source]

cherrypy.test.test_encoding module

class cherrypy.test.test_encoding.EncodingTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testEncoding()[source]
testGzip()[source]
test_UnicodeHeaders()[source]
test_decode_tool()[source]
test_multipart_decoding()[source]
test_multipart_decoding_bigger_maxrambytes()[source]

Decoding of a multipart entity should also pass when the entity is bigger than maxrambytes. See ticket #1352.

test_multipart_decoding_no_charset()[source]
test_multipart_decoding_no_successful_charset()[source]
test_nontext()[source]
test_query_string_decoding()[source]
test_urlencoded_decoding()[source]

cherrypy.test.test_etags module

class cherrypy.test.test_etags.ETagTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_errors()[source]
test_etags()[source]
test_unicode_body()[source]

cherrypy.test.test_http module

Tests for managing HTTP issues (malformed requests, etc).

class cherrypy.test.test_http.HTTPTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

make_connection()[source]
static setup_server()[source]
test_garbage_in()[source]
test_http_over_https()[source]
test_malformed_header()[source]
test_malformed_request_line()[source]
test_no_content_length()[source]
test_post_filename_with_special_characters()[source]

Testing that we can handle filenames with special characters. This was reported as a bug in:

test_post_multipart()[source]
test_request_line_split_issue_1220()[source]
cherrypy.test.test_http.encode_multipart_formdata(files)[source]

Return (content_type, body) ready for httplib.HTTP instance.

files: a sequence of (name, filename, value) tuples for multipart uploads.

cherrypy.test.test_httpauth module

class cherrypy.test.test_httpauth.HTTPAuthTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testBasic()[source]
testBasic2()[source]
testDigest()[source]
testPublic()[source]

cherrypy.test.test_httplib module

cherrypy.test.test_iterator module

class cherrypy.test.test_iterator.IteratorBase[source]

Bases: object

created = 0
datachunk = 'butternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squashbutternut squash'
classmethod decr()[source]
classmethod incr()[source]
class cherrypy.test.test_iterator.IteratorTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_iterator()[source]
class cherrypy.test.test_iterator.OurClosableIterator[source]

Bases: cherrypy.test.test_iterator.OurIterator

close()[source]
class cherrypy.test.test_iterator.OurGenerator[source]

Bases: cherrypy.test.test_iterator.IteratorBase

class cherrypy.test.test_iterator.OurIterator[source]

Bases: cherrypy.test.test_iterator.IteratorBase

closed_off = False
count = 0
decrement()[source]
increment()[source]
next()
started = False
class cherrypy.test.test_iterator.OurNotClosableIterator[source]

Bases: cherrypy.test.test_iterator.OurIterator

close(somearg)[source]
class cherrypy.test.test_iterator.OurUnclosableIterator[source]

Bases: cherrypy.test.test_iterator.OurIterator

close = 'close'

cherrypy.test.test_json module

class cherrypy.test.test_json.JsonTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_cached()[source]
test_json_input()[source]
test_json_output()[source]

cherrypy.test.test_logging module

Basic tests for the CherryPy core: request handling.

class cherrypy.test.test_logging.AccessLogTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase, cherrypy.test.logtest.LogCase

logfile = '/home/docs/checkouts/readthedocs.org/user_builds/cherrypy/envs/latest/lib/python3.5/site-packages/cherrypy/test/access.log'
static setup_server()
testCustomLogFormat()[source]

Test a customized access_log_format string, which is a feature of _cplogging.LogManager.access().

testEscapedOutput()[source]
testNormalReturn()[source]
testNormalYield()[source]
testTimezLogFormat()[source]

Test a customized access_log_format string, which is a feature of _cplogging.LogManager.access().

testUUIDv4ParameterLogFormat()[source]

Test rendering of UUID4 within access log.

class cherrypy.test.test_logging.ErrorLogTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase, cherrypy.test.logtest.LogCase

logfile = '/home/docs/checkouts/readthedocs.org/user_builds/cherrypy/envs/latest/lib/python3.5/site-packages/cherrypy/test/error.log'
static setup_server()
testTracebacks()[source]
cherrypy.test.test_logging.setup_server()[source]

cherrypy.test.test_mime module

Tests for various MIME issues, including the safe_multipart Tool.

class cherrypy.test.test_mime.MultipartTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_multipart()[source]
test_multipart_form_data()[source]
class cherrypy.test.test_mime.SafeMultipartHandlingTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_Flash_Upload()[source]
cherrypy.test.test_mime.setup_server()[source]

cherrypy.test.test_misc_tools module

class cherrypy.test.test_misc_tools.AcceptTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test_Accept_Tool()[source]
test_accept_selection()[source]
class cherrypy.test.test_misc_tools.AutoVaryTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
testAutoVary()[source]
class cherrypy.test.test_misc_tools.RefererTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
testReferer()[source]
class cherrypy.test.test_misc_tools.ResponseHeadersTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
testResponseHeaders()[source]
testResponseHeadersDecorator()[source]
cherrypy.test.test_misc_tools.setup_server()[source]

cherrypy.test.test_objectmapping module

class cherrypy.test.test_objectmapping.ObjectMappingTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testExpose()[source]
testKeywords()[source]
testMethodDispatch()[source]
testObjectMapping()[source]
testPositionalParams()[source]
testTreeMounting()[source]
test_redir_using_url()[source]
test_translate()[source]

cherrypy.test.test_params module

class cherrypy.test.test_params.ParamsTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_error()[source]
test_pass()[source]
test_syntax()[source]

cherrypy.test.test_proxy module

class cherrypy.test.test_proxy.ProxyTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testProxy()[source]
test_no_base_port_in_host()[source]

If no base is indicated, and the host header is used to resolve the base, it should rely on the host header for the port also.

cherrypy.test.test_refleaks module

Tests for refleaks.

class cherrypy.test.test_refleaks.ReferenceTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_threadlocal_garbage()[source]

cherrypy.test.test_request_obj module

Basic tests for the cherrypy.Request object.

class cherrypy.test.test_request_obj.RequestObjectTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testAbsoluteURIPathInfo()[source]
testEmptyThreadlocals()[source]
testErrorHandling()[source]
testExpect()[source]
testHeaderElements()[source]
testParamErrors()[source]
testParams()[source]
testRelativeURIPathInfo()[source]
test_CONNECT_method()[source]
test_CONNECT_method_invalid_authority()[source]
test_basic_HTTPMethods()[source]
test_encoded_headers()[source]
test_header_presence()[source]
test_per_request_uuid4()[source]
test_repeated_headers()[source]
test_scheme()[source]

cherrypy.test.test_routes module

Test Routes dispatcher.

class cherrypy.test.test_routes.RoutesDispatchTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

Routes dispatcher test suite.

static setup_server()[source]

Set up cherrypy test instance.

test_Routes_Dispatch()[source]

Check that routes package based URI dispatching works correctly.

cherrypy.test.test_session module

class cherrypy.test.test_session.MemcachedSessionTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
test()[source]
class cherrypy.test.test_session.SessionTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
tearDown()[source]
test_0_Session()[source]
test_1_Ram_Concurrency()[source]
test_2_File_Concurrency()[source]
test_3_Redirect()[source]
test_4_File_deletion()[source]
test_5_Error_paths()[source]
test_6_regenerate()[source]
test_7_session_cookies()[source]
test_8_Ram_Cleanup()[source]
cherrypy.test.test_session.http_methods_allowed(methods=['GET', 'HEAD'])[source]
cherrypy.test.test_session.setup_server()[source]

cherrypy.test.test_sessionauthenticate module

class cherrypy.test.test_sessionauthenticate.SessionAuthenticateTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testSessionAuthenticate()[source]

cherrypy.test.test_states module

class cherrypy.test.test_states.Dependency(bus)[source]

Bases: object

graceful()[source]
start()[source]
startthread(thread_id)[source]
stop()[source]
stopthread(thread_id)[source]
subscribe()[source]
class cherrypy.test.test_states.PluginTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

test_daemonize()[source]
class cherrypy.test.test_states.ServerStateTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

setUp()[source]
static setup_server()
test_0_NormalStateFlow()[source]
test_1_Restart()[source]
test_2_KeyboardInterrupt()[source]
test_4_Autoreload()[source]
test_5_Start_Error()[source]
class cherrypy.test.test_states.SignalHandlingTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

test_SIGHUP_daemonized()[source]
test_SIGHUP_tty()[source]
test_SIGTERM()[source]

SIGTERM should shut down the server whether daemonized or not.

test_signal_handler_unsubscribe()[source]
class cherrypy.test.test_states.WaitTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_safe_wait_INADDR_ANY()[source]

Wait on INADDR_ANY should not raise IOError

In cases where the loopback interface does not exist, CherryPy cannot effectively determine if a port binding to INADDR_ANY was effected. In this situation, CherryPy should assume that it failed to detect the binding (not that the binding failed) and only warn that it could not verify it.

cherrypy.test.test_states.setup_server()[source]

cherrypy.test.test_static module

class cherrypy.test.test_static.StaticTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

py27_on_windows = False
static setup_server()[source]
static teardown_server()[source]
test_755_vhost()[source]
test_config_errors()[source]
test_error_page_with_serve_file()[source]
test_fallthrough()[source]
test_file_stream()[source]
test_file_stream_deadlock()[source]
test_index()[source]
test_modif()[source]
test_null_bytes()[source]
test_security()[source]
test_serve_bytesio()[source]
test_serve_fileobj()[source]
test_static()[source]
test_static_longpath()[source]

Test serving of a file in subdir of a Windows long-path staticdir.

test_unicode()[source]
static unicode_file()[source]
cherrypy.test.test_static.ensure_unicode_filesystem()[source]

TODO: replace with simply pytest fixtures once webtest.TestCase no longer implies unittest.

cherrypy.test.test_static.error_page_404(status, message, traceback, version)[source]
cherrypy.test.test_static.unicode_filesystem(tmpdir)[source]

cherrypy.test.test_tools module

Test the various means of instantiating and invoking tools.

class cherrypy.test.test_tools.SessionAuthTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_login_screen_returns_bytes()[source]

login_screen must return bytes even if unicode parameters are passed. Issue 1132 revealed that login_screen would return unicode if the username and password were unicode.

class cherrypy.test.test_tools.TestHooks[source]

Bases: object

test_priorities()[source]

Hooks should sort by priority order.

class cherrypy.test.test_tools.ToolTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testBareHooks()[source]
testCombinedTools()[source]
testDecorator()[source]
testEndRequestOnDrop()[source]
testGuaranteedHooks()[source]
testHandlerWrapperTool()[source]
testHookErrors()[source]
testToolWithConfig()[source]
testWarnToolOn()[source]

cherrypy.test.test_tutorials module

class cherrypy.test.test_tutorials.TutorialTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static load_module(name)[source]

Import or reload tutorial module as needed.

classmethod setup_server()[source]

Mount something so the engine starts.

classmethod setup_tutorial(name, root_name, config={})[source]
test01HelloWorld()[source]
test02ExposeMethods()[source]
test03GetAndPost()[source]
test04ComplexSite()[source]
test05DerivedObjects()[source]
test06DefaultMethod()[source]
test07Sessions()[source]
test08GeneratorsAndYield()[source]
test09Files()[source]
test10HTTPErrors()[source]

cherrypy.test.test_virtualhost module

class cherrypy.test.test_virtualhost.VirtualHostTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
testVirtualHost()[source]
test_VHost_plus_Static()[source]

cherrypy.test.test_wsgi_ns module

class cherrypy.test.test_wsgi_ns.WSGI_Namespace_Test(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_pipeline()[source]

cherrypy.test.test_wsgi_unix_socket module

class cherrypy.test.test_wsgi_unix_socket.USocketHTTPConnection(path)[source]

Bases: http.client.HTTPConnection

HTTPConnection over a unix socket.

connect()[source]

Override the connect method and assign a unix socket as a transport.

class cherrypy.test.test_wsgi_unix_socket.WSGI_UnixSocket_Test(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

Test basic behavior on a cherrypy wsgi server listening on a unix socket.

It exercises the config option server.socket_file.

HTTP_CONN = <cherrypy.test.test_wsgi_unix_socket.USocketHTTPConnection object>
pytestmark = [Mark(name='skipif', args=("sys.platform == 'win32'",), kwargs={})]
static setup_server()[source]
tearDown()[source]
test_internal_error()[source]
test_not_found()[source]
test_simple_request()[source]
cherrypy.test.test_wsgi_unix_socket.usocket_path()[source]

cherrypy.test.test_wsgi_vhost module

class cherrypy.test.test_wsgi_vhost.WSGI_VirtualHost_Test(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_welcome()[source]

cherrypy.test.test_wsgiapps module

class cherrypy.test.test_wsgiapps.WSGIGraftTests(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()[source]
test_01_standard_app()[source]
test_04_pure_wsgi()[source]
test_05_wrapped_cp_app()[source]
test_06_empty_string_app()[source]
wsgi_output = 'Hello, world!\nThis is a wsgi app running within CherryPy!'

cherrypy.test.test_xmlrpc module

class cherrypy.test.test_xmlrpc.XmlRpcTest(methodName='runTest')[source]

Bases: cherrypy.test.helper.CPWebCase

static setup_server()
testXmlRpc()[source]
cherrypy.test.test_xmlrpc.setup_server()[source]

cherrypy.test.webtest module

Module contents

Regression test suite for CherryPy.

cherrypy.test.newexit()[source]
cherrypy.test.setup()[source]
cherrypy.test.teardown()[source]