# 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)

  Bases: `object`

  _join_daemon()
  access_log = '/build/cherrypy3-lzdaML/cherrypy3-18.10.0/cherrypy/test/test.access.log'
  config_file = '/build/cherrypy3-lzdaML/cherrypy3-18.10.0/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 = '/build/cherrypy3-lzdaML/cherrypy3-18.10.0/cherrypy/test/test.error.log'
  get_pid()
  join()

    Wait for the process to exit.

  pid_file = '/build/cherrypy3-lzdaML/cherrypy3-18.10.0/cherrypy/test/test.pid'
  start(imports=None)

    Start cherryd in a subprocess.

  write_conf(extra='')

class cherrypy.test.helper.CPWebCase(methodName='runTest')

  Bases: `WebCase`

  _classSetupFailed = False
  _class_cleanups = []
  classmethod _setup_server(supervisor, conf)
  assertEqualDates(dt1, dt2, seconds=None)

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

  assertErrorPage(status, message=None, pattern='')

    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 = {'cpmodpy': <function get_cpmodpy_supervisor>, 'modfastcgi': <function get_modfastcgi_supervisor>, 'modfcgid': <function get_modfcgid_supervisor>, 'modpygw': <function get_modpygw_supervisor>, 'modwsgi': <function get_modwsgi_supervisor>, 'native': <class 'cherrypy.test.helper.NativeServerSupervisor'>, 'wsgi': <class 'cherrypy.test.helper.LocalWSGISupervisor'>, 'wsgi_u': <function get_wsgi_u_supervisor>}
  base()
  date_tolerance = 2
  default_server = 'wsgi'
  do_gc_test = False
  exit()
  getPage(url, *args, **kwargs)

    Open the url.

  prefix()
  scheme = 'http'
  script_name = ''
  classmethod setup_class()
  skip(msg='skipped ')
  classmethod teardown_class()
  test_gc()

class cherrypy.test.helper.LocalSupervisor(**kwargs)

  Bases: `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)

    Load and start the HTTP server.

  stop()
  sync_apps()

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

  using_apache = False
  using_wsgi = False

class cherrypy.test.helper.LocalWSGISupervisor(**kwargs)

  Bases: `LocalSupervisor`

  Server supervisor for the builtin WSGI server.

  get_app(app=None)

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

  httpserver_class = 'cherrypy._cpwsgi_server.CPWSGIServer'
  sync_apps()

    Hook a new WSGI app into the origin server.

  using_apache = False
  using_wsgi = True

class cherrypy.test.helper.NativeServerSupervisor(**kwargs)

  Bases: `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)

  Bases: `object`

  Base class for modeling and controlling servers during testing.

cherrypy.test.helper._test_method_sorter(_, x, y)

  Monkeypatch the test sorter to always run test_gc last in each suite.

cherrypy.test.helper.get_cpmodpy_supervisor(**options)

cherrypy.test.helper.get_modfastcgi_supervisor(**options)

cherrypy.test.helper.get_modfcgid_supervisor(**options)

cherrypy.test.helper.get_modpygw_supervisor(**options)

cherrypy.test.helper.get_modwsgi_supervisor(**options)

cherrypy.test.helper.get_wsgi_u_supervisor(**options)

cherrypy.test.helper.log_to_stderr(msg, level)

cherrypy.test.helper.setup_client()

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