Package turbogears :: Module testutil

Module testutil

source code

Classes
  MemoryListHandler
  TGTest
A WebTest enabled unit testing class.
  BrowsingSession
  DummySession
A very simple dummy session.
  DummyRequest
A very simple dummy request.
  DummyResponse
A very simple dummy response.
  AbstractDBTest
A database enabled unit testing class.
  DBTestSO
  DBTestSA
  DBTest
Functions
 
mount(controller, path="/")
Mount a controller at a path.
source code
 
unmount()
Remove an application from the object traversal tree.
source code
 
make_wsgiapp()
Return a WSGI application from CherryPy's root object.
source code
 
make_app(controller=None)
Return a WebTest.TestApp instance from CherryPy.
source code
 
start_server()
Start the server if it's not already started.
source code
 
stop_server(tg_only=False)
Stop the server and unmount the application.
source code
 
catch_validation_errors(widget, value)
Catch and unpack validation errors (for testing purposes).
source code
 
capture_log(category)
Capture log for one category.
source code
 
print_log()
Print the log captured by capture_log to stdout.
source code
 
get_log()
Return the list of log messages captured by capture_log.
source code
 
sqlalchemy_cleanup() source code
 
set_identity_user(user)
Setup a user for configuring request's identity.
source code
 
attach_identity(req) source code
 
create_request(request, method="GET", protocol="HTTP/1.1", headers={}, rfile=None, clientAddress="127.0.0.1", remoteHost="localhost", scheme="http") source code
 
createRequest(request, method="GET", protocol="HTTP/1.1", headers={}, rfile=None, clientAddress="127.0.0.1", remoteHost="localhost", scheme="http") source code
 
call(method, *args, **kw) source code
 
call_with_request(method, request, *args, **kw)
More fine-grained version of call method.
source code
Variables
  Cookie
  StringIO
  os
  types
  logging
  string
  unittest
  cherrypy
  Request
  Response
  TestApp
  InheritableSQLObject
  sqlobject = None
hash(x)
  sqlalchemy = None
hash(x)
  config
  controllers
  database
  startup
  update_config
  validators
  current_provider
  get_model
  deprecated
  modulename = None
hash(x)
  warnings
  start_cp = deprecated('start_cp is superceded by start_server'...
  reset_cp = deprecated('reset_cp has been superceded by unmount...
  test_user = None
hash(x)
Function Details

mount(controller, path="/")

source code 

Mount a controller at a path. Returns a wsgi application.

make_app(controller=None)

source code 

Return a WebTest.TestApp instance from CherryPy.

If a Controller object is provided, it will be mounted at the root level. If not, it'll look for an already mounted root.

stop_server(tg_only=False)

source code 

Stop the server and unmount the application.

Use tg_only=True to leave CherryPy running (for faster tests).

capture_log(category)

source code 

Capture log for one category.

The category can either be a single category (a string like 'foo.bar') or a list of them. You *must* call print_log() to reset when you're done.

print_log()

source code 

Print the log captured by capture_log to stdout.

Resets that log and resets the temporarily added handlers.

get_log()

source code 

Return the list of log messages captured by capture_log.

Resets that log and resets the temporarily added handlers.

set_identity_user(user)

source code 

Setup a user for configuring request's identity.

Decorators:
  • @deprecated()

attach_identity(req)

source code 
Decorators:
  • @deprecated()

create_request(request, method="GET", protocol="HTTP/1.1", headers={}, rfile=None, clientAddress="127.0.0.1", remoteHost="localhost", scheme="http")

source code 
Decorators:
  • @deprecated("create_request is deprecated. See TestMigration on the TG Wiki")

createRequest(request, method="GET", protocol="HTTP/1.1", headers={}, rfile=None, clientAddress="127.0.0.1", remoteHost="localhost", scheme="http")

source code 
Decorators:
  • @deprecated("create_request is deprecated. See TestMigration on the TG Wiki")

call(method, *args, **kw)

source code 
Decorators:
  • @deprecated("Please see the TestMigration page in the TG wiki.")

call_with_request(method, request, *args, **kw)

source code 

More fine-grained version of call method.

This allows using request/response.

Decorators:
  • @deprecated("Please see the TestMigration page in the TG wiki.")

Variables Details

start_cp

Value:
deprecated('start_cp is superceded by start_server')(start_server)

reset_cp

Value:
deprecated('reset_cp has been superceded by unmount.')(unmount)