| Trees | Indices | Help |
|
|---|
|
|
| Classes | |
|
MockPerm Fake permission class. |
|
|
TestSetup Test suite decorator that allows a fixture to be setup for a complete suite of test cases. |
|
| TestCaseSetup | |
|
EnvironmentStub A stub of the trac.env.Environment class for testing. |
|
| Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| Variables | |
locale_en = Locale('en', territory='US')
|
|
INCLUDE_FUNCTIONAL_TESTS = True
|
|
__package__ =
|
|
Imports: abc, doctest, importlib, inspect, io, logging, numbers, os, shutil, sys, tempfile, time, types, unittest, Locale, trac, Configuration, ComponentManager, ComponentMeta, TracError, DatabaseManager, parse_connection_uri, Environment, PermissionCache, load_workflow_config_snippet, translation, time_now, utc, Request, arg_list_to_args, Chrome, Session
| Function Details |
Simple factory for dummy classes that can be used as replacement for the real implementation in tests. Base classes for the mock can be specified using the first parameter, which must be either a tuple of class objects or a single class object. If the bases parameter is omitted, the base class of the mock will be object. So to create a mock that is derived from the builtin dict type, you can do: >>> mock = Mock(dict) >>> mock['foo'] = 'bar' >>> mock['foo'] 'bar' Attributes of the class are provided by any additional keyword parameters. >>> mock = Mock(foo='bar') >>> mock.foo 'bar' Objects produces by this function have the special feature of not requiring the 'self' parameter on methods, because you should keep data at the scope of the test function. So you can just do: >>> mock = Mock(add=lambda x,y: x+y) >>> mock.add(1, 1) 2 To access attributes from the mock object from inside a lambda function, just access the mock itself: >>> mock = Mock(dict, do=lambda x: 'going to the %s' % mock[x]) >>> mock['foo'] = 'bar' >>> mock.do('foo') 'going to the bar' Because assignments or other types of statements don't work in lambda functions, assigning to a local variable from a mock function requires some extra work: >>> myvar = [None] >>> mock = Mock(set=lambda x: myvar.__setitem__(0, x)) >>> mock.set(1) >>> myvar[0] 1 |
Request object for testing. Keyword arguments populate an
If The following keyword arguments are commonly used: :keyword args: dictionary of request arguments :keyword authname: the name of the authenticated user, or 'anonymous' :keyword method: the HTTP request method :keyword path_info: the request path inside the application Additionally Since: 1.0.11 |
Locates a binary on the path. Returns the fully-qualified path, or None. |
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Mar 30 08:24:26 2020 | http://epydoc.sourceforge.net |